c# – How to determine the device type?

Question:

It is necessary that the application goes into full screen mode only on phones. Tried just that.

ApplicationView view = ApplicationView.GetForCurrentView();
view.TryEnterFullScreenMode();

But, logically, it will switch to full screen both when launched on a PC and on a phone. And to keep track of the screen size on which the application is launched, as for me – crooked … Maybe there is some easier way to specify that phones should have a full screen?

Answer:

You can check the type of device on which the application is running:

var platform = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
if (platform == "Windows.Mobile")
{
    ...
}

Other possible values:

  • Windows.Desktop (if UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse then desktop, otherwise tablet)
  • Windows.Universal (this is an IoT device)
  • Windows.Team (this is the surface hub)

True, Microsoft does not recommend using this property. The official policy is that you shouldn't want to customize the app depending on the platform.

Scroll to Top