Converting to Windows 8 from Windows Phone | Setting up the project (3 of 12)

Now we’ve reached the point where we stop talking and start playing around with some code. As concluded in the previous post on porting strategy, we’ll simply copy the code files from the Windows Phone project and create a new Windows 8 project. It won’t build right away, let alone run, but it’s a start.

The goal for this part is to have a Windows 8 project that does not build but has all the files from the Windows Phone project.

This post is a part in a series – you can find the full index here.

Creating the project

First and all we’ll create our Windows 8 Metro project.

create win8 project

We’ll use the Blank Application template. This is because we want to start clean and create our own thing. But after creating the project we find out that it’s not really empty…

freshly created win8 project

They’ve given us a Common-folder as a getting started gift. It contains some help classes and styles meant to be used when adding new non-empty pages. There is also logic for handling Portrait and Landscape mode. Our app will not support portrait and we have no use for the other stuff, so we’ll remove this folder altogether.

Starting on our own code, we’ll add a class library called Sistaminuten.Common, to mimic the structure of the Windows Phone app.

Moving the files over

Let’s start by comparing the Windows Phone project with the Windows 8 project:

wp7 project

As you can see we have some files to copy. Except for the Views folder, we will copy everything over. The Windows Phone app was codenamed Peach, hence the namespace name.

The easiest way of copying all files over is to first put them in the folder of the Windows 8 project. Then click Show all files in Visual Studio 11, right click on the files and select Include in project.

importing files

That’s it!

Views and ViewModels

As you’ve probably seen already, there are two folders in the Windows Phone project called Views and ViewModels, which of course is a separation of concerns according to the MVVM pattern. MVVM is a pattern that will serve us well in this porting adventure. Please note that we are moving code only, we will not attempt to reuse the XAML, we want to rethink the UI.

If you have separated your views from your view models (and not filled you xaml.cs files with code), ripping out the views will be a painless exercise. But why remove the views? The answer is simple; the views in the phone app is built for a 4” screen and the slate will probably have a screen around 10”. The larger screen size gives us so many more possibilities in designing our views. To scale the UI of the Windows Phone app would simply look stupid. So – out with the old and bring in the new! What can be reused from the Windows Phone views are UI parts – like styles and templates.

Worth mentioning is that the Pivot and Panorama controls are Windows Phone specific. On Windows 8 we have to use other controls like the Grid and FlipView.

This Post Has 6 Comments

  1. Johan Lindfors

    Keep up the good work! But why no Portrait? Taking short-cuts? :)

  2. Andreas Hammar

    Thanks! We don’t see them as short cuts per se, more like an efficient way of bla bla… …just kidding.
    Seriously – in this series we just cover taking the WP app and getting it to spin on Win8. Molding it into a good Win8 app comes next :)

  3. Harish

    Loving the posts :) Well written. Am planning to share it internally in Microsoft

  4. Andreas Hammar

    Thank you Harish. You’re more than welcome to contact us if you have further questions.

Leave a Reply