Sunday, December 1, 2013

Building a cross platform solution for Windows Phone and Windows 8

This is Part 0 of a multi-part series blog post. In this series I will give you a walk through of how you can build a cross platform solution that targets both Windows Phone and Windows 8. I will try and give you pointers on how to keep your code as reusable and clean as possible. We will especially look at a couple of patterns and good practices for this. And in the mean time you will get to know some more advanced MVVM.

But before we start, what are actually the problems you face when trying to target two platforms like Windows Phone and Windows 8? They are both XAML based, right, so this shouldn't be too big of a problem. Well, although both platforms are on the path of convergence, meaning moving towards each other, there are still quite some differences you need to take into account.

One of those differences is the actual XAML you can use on each platform. Although the controls on each platform might be the same, they often live in different namespaces. There are also controls that are specific to either Windows Phone - like the PivotControl - or to Windows 8 - like the FlipView control.

This makes sharing your XAML less obvious.

I wouldn't recommend sharing too much of your XAML between Windows Phone and Windows 8 applications Anyway. You will see that you will mostly try and build a UX experience that is specific for the platform at hand. Keep in mind as well that both platforms support quite different form factors. The things that will be most easy to share will be small pieces of XAML - like things you put into user controls or small data templates.

Apart from differences in your XAML you will also see differences in the actual API's you can use from Windows Phone and Windows 8. Both for instance provide you with an API for navigating between pages in your application, but if you look at the actual Navigate call for each platform, you will find that the call takes different parameters.

This makes it less obvious to share code between the two platforms. However, later in this series, I will show you a technique that will give you quite some advantages for reusing for instance your navigation code.

We just have to use a couple of techniques to get around these differences. I will try and give you some pointers in this series. Mainly I want you to get to know some techniques that will allow you to reuse as much of your business logic (the heart of your application) as possible while targetting multiple platforms.

In this series you will find the following parts (and hopefully, if time permits, more to come):

Part 0: Intro
Part I: Quick sharing of code
Part II: The class library approach
Part III: We need a pattern
Part IV: Mocking out the differences
Part V: Event to command
Part VI: Behaviors for coping with orientation changes
Part VII: Tombstoning

I also recently did a talk on this topic at the 2013 MCT Summit, which got filmed. I hope I can soon add the video of it to this series, so you have some extra reference material there. Other extra reference material to come:

  • A list of useful links on cross platform development
  • The slides of my 2013 MCT Summit talk
  • The start of a little framework you can use to build applications that target Windows Phone and Windows 8 (work in progress for now)
So, hope to see you soon for the first part in this series! I'll keep you posted!


  1. Looks like this will be a great series. Look forward to it.

  2. Thank you! More parts are coming your way soon! :)