Creating the UWP project
Last updated
Was this helpful?
Last updated
Was this helpful?
Now let us create the UWP project based on Xamarin.Forms
. Add a new Blank App (Windows Universal) project to the solution:
Select the proper version of Windows 10:
Install the Xamarin.Forms
package in the NuGet Package Manager:
Or use the command below in the Package Manager Console:
Then install the MvvmCross.Forms
package in the NuGet Package Manager:
Or you can input the command below in the Package Manager Console:
Then add the references to the MvvmCrossDemo.Core
project and the MvvmCrossDemo.Forms.UI
project by right-clicking the MvvmCrossDemo.Forms.Uwp
project in the solution explorer:
Open the App.xaml.cs
file and add a new class with name UWPApplication
, as shown below:
Accordingly, we need update the App.xaml
file to update the base class to make it to inherit from the UWPApplication
class, as shown below:
Open the MainPage.xaml
file and add the reference by this code:
Change the class of the MainPage
to MvxFormsWindowsPage
. The result is:
Open the MainPage.xaml.cs
and remove the base class of it, like this:
Now the UWP project based on Xamarin.Forms
is done. Launch it and you will see the result:
Update the App
class to inherit from UWPApplication
class and remove all the other pre-generated methods except for the constructor. Only keep the InitializeComponent()
method in the constructor. You can find the source code of this file here: . At last, the App.xaml.cs
look like this:
You can find the code of the App.xaml here: .
You can find the source code of this file here: .
Find the sample code here: .