UWP Tips & Tricks #5 – Detect DeviceFamily in Windows App

Since the Universal Windows Platform (UWP) apps run on all the devices powered by Window 10 , you might sometimes want to target a specific device family(eg : mobile or desktop) for certain features.

How to Detect DeviceFamily in UWP Apps ?

You can use the property VersionInfo.DeviceFamily that is defined in the AnalyticsInfo class as shown below.

var DeviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
MessageDialog dialog = new MessageDialog(DeviceFamily);
dialog.ShowAsync();

When you run your UWP app on a desktop environment and using the Local Machine option for deployment , the device family will be displayed as Windows.Desktop.

image

Pin It

One thought on “UWP Tips & Tricks #5 – Detect DeviceFamily in Windows App

  1. Pingback: UWP Tips & Tricks #6 – Acceptance validation error-You cannot submit pre-compiled .Net Native packages | Developer Publish

Leave a Reply

Your email address will not be published. Required fields are marked *