WPF: Show publish version in the app

--- ---

WPF: Show the publish version in the app


  1. MainWindow.xaml
<TextBlock Name="version_lbl"/>
  1. Add a reference to System.Deployment.dll
  2. MainWindow.xaml.cs
using System.Deployment.Application;
...
 public MainWindow()
        {
            InitializeComponent();
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                var _version = ApplicationDeployment.CurrentDeployment.CurrentVersion;
                string v = $"{_version.Major}.{_version.Minor}.{_version.Build}.{_version.Revision}";
                version_lbl.Text = v;
            }
        }
  1. Publish and install the app

Comments

Popular posts from this blog

WPF - Combobox with a null item

Add Cordova and Electron to an Angular App

How to enable CORS between an Angular app and an ASP.Net Web API Service