2

I am building a UWP application. When I open the app settings for my App, I want to display the Version number of my application in the Specifications section.

For example- In the following image, you can see the version number as 1.2.4.0 under the Specifications section in the App settings. How can I do a similar thing for my UWP application.

Image

How can I achieve this?

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
Pulkit Mehta
  • 109
  • 2
  • 9
  • please read this guidance and take action accordingly so we can either close or improve this question/answer for the benefit of the community: https://stackoverflow.com/help/someone-answers – Stefan Wick MSFT Feb 09 '19 at 19:32

3 Answers3

5

See: Retrieve the Current App version from Package That's how you can display it anyway.

        public string GetAppVersion()
    {

        Package package = Package.Current;
        PackageId packageId = package.Id;
        PackageVersion version = packageId.Version;

        return "Version " + string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);

    }
UnskilledBuild
  • 264
  • 1
  • 3
  • 12
2

The UWP Community Toolkit has a SystemInformation class which has many relevant properties and methods.

You could use it to get the information that you want.

For example,

// To get application's name:
public string ApplicationName => SystemInformation.ApplicationName;

// To get application's version:
public string ApplicationVersion => $"{SystemInformation.ApplicationVersion.Major}.{SystemInformation.ApplicationVersion.Minor}.{SystemInformation.ApplicationVersion.Build}.{SystemInformation.ApplicationVersion.Revision}";
Xie Steven
  • 8,544
  • 1
  • 9
  • 23
1

You get this for free, nothing special needs to be done. The App settings page will display the version number retrieved from your appxmanifest file.

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51