Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Reusing code for Windows Phone 7, 8 and 8.1

From Wiki
Jump to: navigation, search
Featured Article
11 May

The advent of Windows Phone 8.1 poses a problem to long-time Windows Phone developers - Visual Studio 2013 does not support WP 7 anymore and Visual Studio 2012 does not support WP 8.1 yet. This article shows a way out of that dilemma.

WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
Article Metadata
Code ExampleTested with
SDK: Windows Phone 7.1 SDK, Windows Phone 8.0 SDK, Windows Phone 8.1 SDK
Created: influencer (21 Apr 2014)
Last edited: influencer (16 May 2014)



Up until now, developers of Windows Phone 7 and Windows Phone 8 apps were able to use Visual Studio 2012 for a multi-project solution that supported both platforms. Since the newer Visual Studio 2013 no longer supports WP 7, that was the only way to quickly switch between both projects in development.

A common way to share code between these two platforms is to keep the C# source just in one project and add it to the other as a link (see Performing code reuse in Windows Phone ).

If the new features of Windows Phone 8.1 are desirable for an app - and who doubts that - the first idea is to add just another project for the WP 8.1 variant and share some code there, too. But wait - VS 2012 does not support WP 8.1 projects. You have to use VS 2013 Update 2 if you want to create a WP 8.1 solution.

So do you have to drop support for WP 7 in order to get the new WP 8.1 features? And then leave your paying WP 7 users with an unsupported app?

No, you don't!

Keep calm and carry on

Idea for a solution

The Visual Studio project format has not significantly changed since VS 2010. It is in general possible to open a solution created in VS 2012 in VS 2013, save it there, and then open it in VS 2012 again.

Opening a VS 2012 solution that contains a WP 7 project in VS 2013 produces a warning. The WP 7 project can't be opened but remains intact. The other projects in the solution are usable and working with the solution does not render it defective.


It is possible to create a WP 8.1 project in VS 2013 Update 2 and add it to a WP 7/8 solution. You can add source code files from the WP 7 project as a link, even if the project cannot be opened in VS 2013.

Here's a sample of a mixed Solution in VS 2012. We have a WP7 project, a WP8 project and a WP8 project that's the source for a new version based on future capabilities (WP8NTapp).


After work in the WP 8.1 project is done, the solution can be opened in VS 2012 again in order to maintain the WP 7 project. As with the WP 7 project in VS 2013, VS 2012 will not open the WP 8.1 project, but the remaining projects in the solution can be used.

VS 2013 shows the following dialog:


Note.pngNote: It is important to check off the checkbox for the WP7 project(s).

The solution is shown in VS 2013 as follows:


The next step is to convert the WP8NTapp to Silverlight 8.1 using the 'Retarget to Windows Phone 8.1' context menu command. The solution changes as follows but the linked source files are intact:


Opening the solution in VS 2012 again renders the WP8NTapp project temporarily incompatible:



It's a bit uncomfortable to handle the solution in two versions of Visual Studio, but at least it is possible to maintain all three platforms without loss. Even shared code from an unsupported project version is allowed.

This page was last modified on 16 May 2014, at 16:36.
265 page views in the last 30 days.