Here a simple portable way to get the current device family:
/// <summary>
/// All the device families
/// </summary>
public enum DeviceFamily
{
Desktop,
Mobile,
Iot,
Xbox,
}
/// <summary>
/// The helper to get the current device family
/// </summary>
public static class DeviceFamilyHelper
{
/// <summary>
/// Return the family of the current device
/// </summary>
/// <returns>the family of the current device</returns>
public static DeviceFamily GetDeviceFamily()
{
switch(ResourceContext.GetForCurrentView().QualifierValues["DeviceFamily"].ToLowerInvariant())
{
case "mobile": return DeviceFamily.Mobile;
case "xbox": return DeviceFamily.Xbox;
case "iot": return DeviceFamily.Iot;
default: return DeviceFamily.Desktop;
}
}
}