我有一个现有的Xamarin Forms应用程序,可以为Android和iOS构建。我想添加一个UWP目标,以便我可以看到该应用程序在Windows上的表现。我假设我可以这样做,而无需为Windows创建新的UI?
我在Windows 10上使用Visual Studio 2015。
你应该能够遵循这个Xamarin documentation page
旧xamarin.com链接old documentation page
它包含几个步骤,一切都在Visual Studio中,因为Xamarin Studio不支持UWP:
OnLaunched
方法中编辑App.xaml.cs(模板中的第63行): // under this line
rootFrame.NavigationFailed += OnNavigationFailed;
// add this line
Xamarin.Forms.Forms.Init (e); // requires the `e` parameter
Page
标签中的所有内容,它应该是一个空的Grid
标签。xmlns:forms="using:Xamarin.Forms.Platform.UWP"
Page
标记更改为forms:WindowsPage
Page
的继承,使它成为public sealed partial class MainPage // REMOVE ": Page"
LoadApplication
,如下所示: // below this existing line
this.InitializeComponent();
// add this line
LoadApplication(new YOUR_NAMESPACE.App());
另请注意,您必须提供图像等资源,并添加您可能已安装在其他项目中的所有使用过的NuGet软件包,例如您正在使用的插件。在后一种情况下,最好检查是否所有包都可用于UWP。
还有一些已知问题: