I have an existing Xamarin Forms app that's setup to build for Android and iOS. I want to add a UWP target so I can see how the app performs on Windows. I assume I can do this without having to create a new UI for Windows?
I'm using Visual Studio 2015 on Windows 10.
You should be able to following this Xamarin documentation page
Old xamarin.com link old documentation page
It consists of a couple of steps, everything is in Visual Studio as UWP is not supported in Xamarin Studio:
OnLaunched
method (around line 63 in the template) do: // under this line
rootFrame.NavigationFailed += OnNavigationFailed;
// add this line
Xamarin.Forms.Forms.Init (e); // requires the `e` parameter
In MainPage.xaml remove all content in the Page
tags, it should be an empty Grid
tag.
Also in the MainPage.xaml add this namespace: xmlns:forms="using:Xamarin.Forms.Platform.UWP"
Still in the MainPage.xaml change the Page
tag to forms:WindowsPage
In the MainPage.xaml.cs remove the inheritance of Page
so it becomes public sealed partial class MainPage // REMOVE ": Page"
Still in the MainPage.xaml.cs add the LoadApplication
in the constructor like this:
// below this existing line
this.InitializeComponent();
// add this line
LoadApplication(new YOUR_NAMESPACE.App());
Also note you do have to provide the resources like images and add all used NuGet packages that you might have installed in other projects like plugins you're using. In the latter case, it is probably best to check if all packages are available for UWP.
There are a couple of known issues as well:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With