In this chapter, we will learn how to port your existing app Windows 8.1 application to the Universal Windows Platform (UWP). You can create a single Windows 10 app package that your customers can install onto all types of devices.
After porting your application to the Windows 10 UWP, your app will benefit from −
There are two options to port your existing Windows 8.x application to Universal Windows Platform (UWP).
Option 1 − One is to create a new Windows 10 project in Visual Studio and copy your files into it.
Option 2 − The other option is to edit a copy of your existing project files, including the app package manifest.
Below given are the main steps while using the first option.
Launch Microsoft Visual Studio 2015 and create a new Blank Application (Windows Universal) project with the name UWPBookStore.
Your new project builds an app package (an appx file) that will run on all device families.
In your Universal 8.1 app project, identify all the source code files and visual asset files that you want to reuse. Shown below is a sample application, which has three projects. One is used for Windows, the second one is for mobile and the third one is the shared project for Windows and mobile.
After running this application on phone, you will see the following window.
After running the window application, you will see the following application.
From the Shared Project, copy the folder Assets\CoverImages containing the book cover image (.png) files. Also copy the ViewModel folder and the MainPage.xaml and replace the file in the destination.
From the Windows project, copy BookstoreStyles.xaml. All the resource keys in this file will resolve in a Windows 10 app. Some of those in the equivalent WindowsPhone file will not.
In the Solution Explorer, make sure Show All Files is toggled ON.
Select the files that you copied, right-click them, and click Include In Project as shown below.
This will automatically include their containing folders. You can then toggle Show All Files ‘OFF’ if you like.
Now your project structure will look like this in Solution Explorer.
Edit the source code and markup files that you just copied and change any references to the Bookstore1_81 namespace to UWPBookStore namespace.
The easiest way is to replace the name space with Replace In Files feature. No code changes are needed in the view model.
Now, when the above code is executed, you can run it on a local machine as well as on a mobile as shown below.
Now, the second option is to edit a copy of your existing project files, including the app package manifest. The project file and the package.appmanifest file need some modifications when porting from Windows/phone 8.x to Windows 10.
Microsoft has provided UWP project upgrade utility, which is very helpful while porting your existing application. The utility can be downloaded from github.com.
We recommend you to follow the above examples step by step for better understanding.