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

Leave A Reply

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

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...