Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Detect device type on Universal Windows Platform (UWP)
using Windows.System.Profile;
using Windows.UI.ViewManagement;
namespace Wagonli.Tools
{
public static class DeviceTypeHelper
{
public static DeviceFormFactorType GetDeviceFormFactorType()
{
switch (AnalyticsInfo.VersionInfo.DeviceFamily)
{
case "Windows.Mobile":
return DeviceFormFactorType.Phone;
case "Windows.Desktop":
return UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse
? DeviceFormFactorType.Desktop
: DeviceFormFactorType.Tablet;
case "Windows.Universal":
return DeviceFormFactorType.IoT;
case "Windows.Team":
return DeviceFormFactorType.SurfaceHub;
default:
return DeviceFormFactorType.Other;
}
}
}
public enum DeviceFormFactorType
{
Phone,
Desktop,
Tablet,
IoT,
SurfaceHub,
Other
}
}
@ifegade
Copy link

ifegade commented Oct 20, 2016

Thanks

@shanew-L4
Copy link

shanew-L4 commented Nov 1, 2016

Doesn't support Xbox :P

@jkronk
Copy link

jkronk commented Nov 10, 2016

Very cool thanks mate

@lindexi
Copy link

lindexi commented Jun 16, 2017

Good

@DashPriyabrata
Copy link

DashPriyabrata commented Aug 8, 2017

Nicely Done! Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment