Remove default borders (safe space)

When you finally manage to successfully deploy your game on the Xbox One, (and I do hope I wasn’t the only one who seemed to hit every problem possible in doing so!) one of the first things you may notice is a big chugly border surrounding your masterpiece. These borders are put here by default to cater for safe space and will vary depending on the device you are viewing on. However, if you’ve done your homework and already catered for this, you can simply remove these borders by placing the following line of code in the OnLaunched event of your App.xaml.cs

// Set UI to edge of screen (for Xbox One)Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);

Boom! No more chugliness!


Turn off mouse mode

By default mouse mode is enabled for all UWP applications you just maybe didn’t notice because you were either running on a PC which had a mouse connected already or a Windows Phone which relied on touch input in place of the mouse pointer. Anyhow, to hide the mouse pointer on Xbox One, place the following line of code in the constructor of your App.xaml.cs

// Disable mouse mode
this.RequiresPointerMode = Windows.UI.Xaml.ApplicationRequiresPointerMode.WhenRequested;


Prevent default navigation sounds

If you’ve made a great app or game with your own sounds and music, then another minor annoyance is the addition of default navigation sounds, again, exclusively on Xbox One. To turn these off, add this line of code in the constructor of your App.xaml.cs

// Prevent default UWP sounds
ElementSoundPlayer.State = ElementSoundPlayerState.Off;


Detect whether you are running on Xbox

Sometimes you may just want to change part of the UI or some specific behaviour when running on Xbox. For example, you may want to change the text “Tap to start” to “Press A to start” You can check this by adding a static bool property in your App.xaml.cs like so…

// Determines whether app is running on Xbox
public static bool RunningOnXbox => Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily.ToLower().Contains(“xbox”);

Then, wherever you need to you can check this property and do some stuff…

if (App.RunningOnXbox)
// Do some stuff…

A perfect example of using this is when turning off mouse mode or disabling default sounds as mentioned above!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s