Morse Coder Part 8 : Windows 10 Migration

I’m sure you’re probably all aware that Windows 10 is out, (if not in the news then the nagging to upgrade), I recently took the plunge and upgraded my PC and tablet and have to say I’m rather impressed.  Along with the Operating System I also upgraded my development environment to Visual Studio 2015 Community to start taking a look at Windows 10 Apps, (and maybe start dabbling in Xamarin now that it’s so accessible).  In light of this, now seems as good a time as any to start looking at implementing our Morse Coder App as a Windows 10 Universal App.

Outcome

Windows 10 Universal Apps differ from Windows 8.1 and Windows Phone 8.1 apps in that they require only a single Project for the UI, where the 8.1 apps would have had Windows, Windows Phone, and a Shared Project; Windows 10 requires only a single project.  By the end of this post we should have a functioning Windows 10 app, with all the current functionality from the existing Desktop Version, running on both the Phone Emulator and the Desktop (and everything in between).

Prerequisites

Implementation

Project Creation

Start by adding a new Project to the Solution.  On upgrading to Visual Studio 2015, there should now be a new set of Project Templates added to the ‘Add New Project’ Dialog :

Add New Project - Universal Windows
Add New Project – Universal Windows

We’re interested in the Blank App (Universal Windows) Template, so add this to your solution :

SolutionStructure.png

We now have a clean slate that we can start to migrate over the existing functionality, as above, we’ll be focussing on the Windows Version to base our migration on.

References

We’ll need to add a reference to the PCL we created in Part 2 :

Morse Coder PCL Reference
Morse Coder PCL Reference

Because we put the logic of our application inside a common Portable Class Library, we won’t need to ‘port’ any of this over to our new Project, but we will look at re-targeting the platforms that our PCL will run on in a little while.

We’ll also need to pull in a reference to the MvvmLightLibs as in Part 1.

Code and UI

Copy the 4 folders in the Shared Project – Design, Interfaces, UserControls, ViewModel, ensure that your solution still builds :

SharedFolders.png

Now let’s look at the App.xaml file we left behind, we don’t want to copy that over as-is as there are Windows Phone Compiler directives in there that are no longer relevant, but we do want to copy over our ViewModelLocator Application resource and the required namespace declarations, copy them over manually, you should end up with :

<Application x:Class="MorseCoder.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MorseCoder" RequestedTheme="Light" xmlns:vm="using:MorseCoder.ViewModel" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

<Application.Resources>
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
</Application.Resources>
</Application>

Now we can copy over the MorseCoderSettings Class and the MainPage.xaml into the Universal Project.

At this point we should have a compiling, and running (don’t forget to deploy), solution, from Windows 10…

Windows10.png

…and from the Windows 10 Phone Emulator…Windows10-Phone.png

The UI is way off but functionally we’re in business!

We have a bit of tidying up to do, we can now safely remove the old projects from our solution, (they’re version controlled so we can always refer back to them if needed!).  Click on each of the Windows, Windows Phone and the Shared project and delete them, we should now be left with 3 projects, with our new one resembling :

Clean Windows 10 Universal Project Structure
Clean Windows 10 Universal Project Structure

Now all that’s left is to re-target the PCL, the API seems to be largely unchanged between Windows 8 and 10, but we will make the change to our PCL project for completeness.  Right click the PCL Project, Properties > Library Tab > Targeting > Targets > Change…, deselect Windows Phone 8.1 and alter the Windows target to Windows Universal 10.0 :

Windows 10 Target
Windows 10 Target

As usual my GitHub Repository has been updated accordingly, feel free to Fork and have a play.

Summary

We took a bit of a detour with this Post to make us target Windows 10 and do a bit of future proofing (and save work looking at a single codebase!), hopefully this will be useful.

Where are we?

  • We’ve upgraded our Windows 8.1 Universal App Projects to a Windows 10 Universal App Project.

Where are we heading?

We’ll look at :

  • addressing the Windows Phone UI;
  • adding Morse to Alphabet Translation to the UI;
  • methods of serialising POCOs to Application Settings;
  • Messaging between ViewModels using MVVM Light.

1 thought on “Morse Coder Part 8 : Windows 10 Migration”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s