0

Is there any way to detect/check from C# code if the application is running on Xbox or a PC?

Something like:

if (Environment.IsXbox)
{
    // Do Xbox specif stuff
}
Vinicius Jarina
  • 797
  • 5
  • 16

1 Answers1

1

Check if UWP application is running on Xbox

For this scenario, you could use SystemInformation that comes from Microsoft.Toolkit. For getting current device family. please use following code directly.

if (SystemInformation.DeviceFamily=="Windows.Xbox"){
// Do Xbox specif stuff
}
Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • 1
    According to the [source code](https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/rel/7.1.0/Microsoft.Toolkit.Uwp/Helpers/SystemInformation.cs#L53) of `Microsoft.Toolkit`, if you only need `DeviceFamily`, you can use `Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily`. – Victor Jul 08 '22 at 09:07