如何将UWP目标添加到现有的Xamarin Forms项目?

问题描述:

我有一个现有的Xamarin Forms应用程序,可以为Android和iOS构建。我想添加一个UWP目标,这样我就可以看到应用程序在Windows上的表现。我假设我可以做到这一点,而无需为Windows创建新的用户界面?如何将UWP目标添加到现有的Xamarin Forms项目?

我使用Visual Studio 2015年在Windows 10

+0

https://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/ – magicandre1981

你应该能够跟随这Xamarin documentation page

它包括几个步骤的,一切都在Visual Studio中作为不支持UWP在Xamarin Studio中:

  1. 在您的解决方案中添加一个干净的UWP项目。
  2. 的Xamarin.Forms NuGet包添加到您的UWP项目,确保版本同步与其他项目
  3. 构建>配置管理器确保您UWP项目正在构建和部署

Building and deploying your UWP app

  1. 右击项目>添加>参考和引用您PCL或共享项目
  2. Referencing your shared project

    1. 修改您App.xaml.csOnLaunched方法(围绕在模板线63)的更多信息:
    2. // under this line rootFrame.NavigationFailed += OnNavigationFailed; // add this line Xamarin.Forms.Forms.Init (e); // requires the `e` parameter

      1. In MainPage.xaml删除中的所有内容标签,它应该是一个空的Grid标签。

      2. 另外在MainPage.xaml中添加这个命名空间:xmlns:forms="using:Xamarin.Forms.Platform.UWP"

      3. 仍然在MainPage.xaml中改变Page标签forms:WindowsPage

      4. MainPage.xaml.cs中删除Page的继承,所以它变成public sealed partial class MainPage // REMOVE ": Page"

      5. 仍然在MainPage.xaml.cs中在构造函数中添加LoadApplication这样的:

      // below this existing line this.InitializeComponent(); // add this line LoadApplication(new YOUR_NAMESPACE.App());

      还要注意你必须提供的资源,如图像,并添加所有使用的NuGet包。在后一种情况下,最好检查是否所有软件包都可用于UWP。

      有几个已知问题,以及:

  • 一些看法/网页的外观,还没有最后定下来大约有导航文本对齐一对夫妇 知不速之客可能不是完美的 一些标题
开始=> 开始=>