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.

Revision as of 12:05, 10 September 2013 by pavan.pareta (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to display the app version on a Windows Phone page

From Wiki
Jump to: navigation, search

It's not as simple as it may seem to display the current app version in a Windows Phone 7 app. Here you'll see how this can be solved.

WP Metro Icon UI.png
SignpostIcon XAML 40.png
WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
Article Metadata
Code ExampleTested with
Devices(s): Lumia 800, Lumia 620, Lumia 920
Platform(s): Windows Phone 7 Silverlight and later
Windows Phone 8
Windows Phone 7.5
Created: influencer (03 Nov 2012)
Updated: influencer (09 Sep 2013)
Last edited: pavan.pareta (10 Sep 2013)

Necessary Steps

In a Windows Phone app there are at least two places where a version number is entered:

  • The WMAppManifest.xml file and
  • the AssemblyInfo of the main app assembly.

Both numbers should be kept equal.

The version number is compiled into the assembly by Visual Studio and can be queried there with the GetCustomAttributes of the executing assembly GetExecutingAssembly.

So what you'll have to do first is keeping the version number in those two places accurate.


[assembly: AssemblyVersion("")]



Next add a GetVersion() method to the App.xaml.cs code-behind file that reads out the version number:

public static string GetVersion()
var versionAttribute = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).FirstOrDefault() as AssemblyFileVersionAttribute;
if (versionAttribute != null)
return versionAttribute.Version;
return "";

Then you can show the version number on a page by setting the text of a TextBlock, e.g. in the constructor of the page:

ApplicationTitle.Text += " Version " + App.GetVersion();


Sample Code

Sample code to this article is contained in the Media: sample code for the Collection of Value converters for Windows Phone apps.

This page was last modified on 10 September 2013, at 12:05.
268 page views in the last 30 days.