简体   繁体   English

Xamarin Visual Studio 2017:无法添加跨平台视图页面

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

So I use the Xamarin Cross-Platform application template. 所以我使用Xamarin跨平台应用程序模板。 I want to add LoginPage.xaml view to my project. 我想将LoginPage.xaml视图添加到我的项目中。 So I choose add -> new item -> contentpage . 所以我选择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". 没有在项目“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 Microsoft Visual Studio

Exception of type "System.Exception" was thrown. 抛出了“System.Exception”类型的异常。

Then what happenend next is the "LoginPage.xaml" file is created but not included in the project (it is hidden). 然后接下来发生的是“LoginPage.xaml”文件已创建但未包含在项目中(它是隐藏的)。 I cannot include it in my project because it keeps refusing. 我不能将它包含在我的项目中,因为它一直拒绝。 There is no xaml.cs file created. 没有创建xaml.cs文件。

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: 此问题正式“正在调查中”(已报告并回答: https//developercommunity.visualstudio.com/content/problem/160939/bug-adding-xaml-content-page-to-shared-project-xam.html )和有一个解决方法:

a workaround is to install the Universal Windows Platform development workload 解决方法是安装通用Windows平台开发工作负载

The best I could do was actually add it in a different version of Visual Studio. 我能做的最好的事实是将它添加到不同版本的Visual Studio中。 I just happened to have both 2015 and 2017 installed. 我碰巧安装了2015年和2017年。 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. 我的VS 2015没有给我很多模板选项,所以我最终制作了内容页面,后来又将标记更改为掌握或我需要的任何内容。 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. 仅供参考,我还发现有时候我可以添加一个XAML页面,但它将.xaml和.xaml.cs分开而不是嵌套它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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