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

This comment has been minimized.

ifegade commented Oct 20, 2016

Thanks

@shanew-L4

This comment has been minimized.

shanew-L4 commented Nov 1, 2016

Doesn't support Xbox :P

@jkronk

This comment has been minimized.

jkronk commented Nov 10, 2016

Very cool thanks mate

@lindexi

This comment has been minimized.

lindexi commented Jun 16, 2017

Good

@DashPriyabrata

This comment has been minimized.

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