简体   繁体   中英

Xamarin Visual Studio 2017: Cannot Add Cross-Platform View Page

So I use the Xamarin Cross-Platform application template. I want to add LoginPage.xaml view to my project. So I choose add -> new item -> contentpage .

There is always error:

The project system has encountered an error:

Did not find new element in the hierarchy for item "Views\\LoginPage.xaml". The item would have been added with type "Page". The project item schema service knows about this item type. The item does exist in the project file.

After I close the error. There is another error:

Microsoft Visual Studio

Exception of type "System.Exception" was thrown.

Then what happenend next is the "LoginPage.xaml" file is created but not included in the project (it is hidden). I cannot include it in my project because it keeps refusing. There is no xaml.cs file created.

How can I fix this?

This issue is officially "Under Investigation" (reported and answered: https://developercommunity.visualstudio.com/content/problem/160939/bug-adding-xaml-content-page-to-shared-project-xam.html ) and there is a workaround:

a workaround is to install the Universal Windows Platform development workload

The best I could do was actually add it in a different version of Visual Studio. I just happened to have both 2015 and 2017 installed. My VS 2015 didn't give me as many options for templates, so I ended up making content pages and later changing the markup to master or whatever I needed. Just FYI, I've also found that sometimes I can add an XAML page, but it separates the .xaml and .xaml.cs instead of nesting them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM