Best Practices for Migrating Windows 7 Desktop Apps to Windows Store Apps
Windows 8 introduces a new breed of application called Windows Store or WinRT apps (formerly called “Metro-style” apps). You can build Windows Store apps using a variety of different development languages:
- XAML and (VB or C# or C++)
- DirectX and (C++ or (C# using SharpDX))
In this article, I will look at how to convert existing code to a Windows Store app for Windows 8. I have previously compiled a list of migration resources in a Porting Apps to Windows 8 Metro blog post, too.
Let me start with some general guidance for migrating an application to a Windows Store app. Now, keep in mind that you don’t simply convert an existing desktop application to a Windows Store app line-by-line; you should redesign it for the new user experience.
If you are migrating a desktop app that was written using the .NET Framework, begin by reading Converting your existing .NET Framework code. This article illustrates the changes in UI, I/O, storage, networking, threading, reflection, security, resources, exceptions, WCF, and types.
Next, here are some things to consider when migrating:
Use the Visual Studio templates – Many templates are available in Visual Studio to speed up your app development. Some templates include support for certain Windows 8 features (like snap), have some navigation already baked in, and follow the design guidelines. The easiest path to building a Windows Store app may be to create a new project using a project template, and then copy/paste bits of your existing code into the template, refactoring where necessary.
- Overview of all project and item templates
- C#, VB, and C++ project templates
- C#, VB, and C++ item templates
Follow the design guidance – There is a wealth of design guidance for Windows Store apps at http://design.windows.com. There are some high-level principles around layout, interactions, and navigation. These are summarized nicely in a Design talk that is given at the Windows Developer Boot Camp events, if you have a chance to attend one. If not, you could browse through the slides from that talk, which can be downloaded as part of the Windows 8 Camp in a Box. As a developer of Windows Store apps, I frequently refer to the UX guidelines as well. Bookmark that page! It clearly describes guidelines for everything from animations to globalization to touch to controls, which is awesome for developers like me who don’t consider themselves good at design. There are also some articles focused on design considerations when porting to a Windows Store app, such as Design case study: Website to Windows Store app.
Asynchronous Operations – Windows Store apps must be “fast and fluid”. They must meet the performance criteria of launching within 5 seconds and suspending within 2 seconds on a low-power computer. There is support to help you enable this in the WinRT APIs, in the form of many asynchronous methods (the convention is to end the name of an asynchronous method with “Async”). Therefore, when porting your application, consider what operations should be done asynchronously (like file I/O, opening network connections, etc.) and leverage the appropriate asynchronous methods in WinRT. For further information, here is a quickstart on calling asynchronous APIs and an article on asynchronous programming in Windows Store apps.
Leverage the Windows 8 features – Another step in your porting process is adding Windows 8 functionality that lets your Windows Store app really shine. Implement a snap view. Integrate with the charms bar using contracts to do search/share/settings. Define a nicely branded tile for your app, and use secondary tiles or live tiles as needed. Use notifications where appropriate. Leverage roaming capabilities. And so forth…
Change the default tile logos and splash screen – The Visual Studio project templates will provide default .png images for your app’s logos and splash screen in the Assets folder. You should replace these with your own images. Open the Package.appxmanifest to point to new images if they have different names than the defaults. For more information, here is a quickstart on creating a default tile and a quickstart on adding a splash screen.
Declare any capabilities that you need – There are certain potentially sensitive things that Windows Store apps can do on a user's machine, such as access the Pictures library or use the webcam. If an app wants to do these things, the developer must declare a capability in the app's manifest. You can declare capabilities by using the Manifest Designer in Visual Studio or you can add them manually to the package manifest as described in How to specify capabilities in a package manifest. Then, when users download the app from the Windows Store, they can clearly see if the app is using any of this functionality. More info and a list of all of the capabilities is provided at App capability declarations.
Run the Windows App Certification Kit tool – Before you submit your app to the Windows Store, make sure that you have tested it with the Windows App Certification Kit (WACK). Here is “how-to” information on this. This same series of tests is run during the Windows Store application submission process, so it’s better to run it locally first and make sure everything passes there before submitting. You definitely won’t get into the Store if this series of tests doesn’t pass!
Now, certain types of apps may be easier to port to Windows Store apps than others. Let’s examine a few categories of applications:.NET Framework code
If you are migrating a desktop app that was written using the .NET Framework, begin by reading Converting your existing .NET Framework code. This article illustrates the changes in UI, I/O, storage, networking, threading, reflection, security, resources, exceptions, WCF, and types.WPF, Silverlight, or Windows Phone (XAML)
If you are migrating an application that is already developed in XAML, then porting to a XAML Windows Store app will be easiest. Here are some resources to help:
- Migrating a Windows Phone 7 app to XAML Metro app – this article looks at porting a WP7 app written in Silverlight to a Metro app written in XAML. This includes some helpful info, like a mapping of the Silverlight and Windows Phone namespaces and their equivalents in WinRT, and a list of differences in the UI capabilities.
- Porting Silverlight or WPF XAML/code to Metro app – this article examines the major differences between Metro apps and other XAML apps, and gives some advice on converting projects.
If you are migrating a website already developed in HTML, then porting to an HTML5 Windows Store app will be easiest. Here are some resources to help:
- Rethinking a website as a Metro app – this article is focused on design and shows the process of reimagining a food truck website as a Metro app
- Migrating a website to Metro app – this short article is focused on development and discusses some back-end considerations like communication, streaming, security, client package deployment, data sharing, and syndication
If you are migrating an XNA application to a Windows Store app, you can use a technology like MonoGame, which is an open-source implementation of XNA that enables developers to port their games to non-Microsoft platforms (like iOS, Android, etc.) as well as Windows 8. My teammate Bob Familiar wrote a three-part blog post series on Windows 8, XNA, and MonoGame:
If you are migrating a C++ application to a Windows Store app, watch the Porting a desktop app to a Metro style app video by Sridhar Madhugiri, which contains many useful tips specific to C++. You can download the slides as well.
Download Windows 8 and Visual Studio Express 2012 for Windows 8. Another useful resource is the “30 to launch” program, which helps you build a Windows Store app in 30 days by providing tips and access to free design consultations and free phone support from a Windows architect.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)