How to Get the Device Platform in Windows 10 App ?

If you running your App on Windows 10 , you might want to get the device platform from your app for some reasons. If this is the case , you can use the DeviceFamily property defined in the Windows.System.Profile.AnalyticsInfo.VersionInfo class.

Below is the sample code snippet demonstrating the usage of this.

How to Get the Device Platform in Windows 10 App ?

public void DisplayPlatform()
{
    var platformFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
    MessageDialog dialog = new MessageDialog(platformFamily);
    dialog.ShowAsync();
}
image

The complete codebehind file is below.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace Win10App
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            DisplayPlatform();
        }
        public void DisplayPlatform()
        {
            var platformFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
            MessageDialog dialog = new MessageDialog(platformFamily);
            dialog.ShowAsync();
        }
    }
}