All I needed this helper to do was to tell me whether my application was running on a Phone or Tablet device. For me I don't really fined it necessary to need to differentiate Desktop and Tablet for me its the same thing( for my UWP apps).
And for the fun i added Xbox so that you can also check if your appliction is running on a Windows 10 Xbox (Thanks @RudyHuyn)
Thus I ended up with this:
public static class DeviceTypeHelper { public static DeviceTypeEnum GetDeviceType() { switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Desktop": return DeviceTypeEnum.Tablet; case "Windows.Mobile": return DeviceTypeEnum.Phone; case "Windows.Universal": return DeviceTypeEnum.IoT; case "Windows.Team": return DeviceTypeEnum.SurfaceHub; case "Windows.Xbox": return DeviceTypeEnum.Xbox; default: return DeviceTypeEnum.Other; } } } public enum DeviceTypeEnum { Phone, Tablet, IoT, Xbox, SurfaceHub, Other }
My gist: https://gist.github.com/Delaire/37cbe07738df34bfd5e8
Original gist: https://gist.github.com/wagonli/40d8a31bd0d6f0dd7a5d