🛠 3.8 NuGet XBOX Template Fullscreen Fix

I posted this in one of my other threads but wanted it to be more prominent and easier to find and also easier to hand for fellow devs.

FIX FULLSCREEN ON XBOX: for broken templates

Fix for UWP 3.8DevBranch template

You need to have:

using System;
...
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
...
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
...
using Windows.UI.Xaml.Navigation;

In your App.xaml.cs

And then just at the start of everything:

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
    static string deviceFamily;

Add that field static string deviceFamily;

And add:

    //API check to ensure the "RequiresPointerMode" property exists, ensuring project is running on build 14393 or later
    if (Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Application", "RequiresPointerMode"))
    {
        //If running on the Xbox, disable the default on screen pointer
        if (IsXbox())
        {
            Application.Current.RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested;
        }
    }

Before the closing bracket of public App()

And then add:

/// <summary>
/// Detection code in Windows 10 to identify the platform it is being run on
/// This function returns true if the project is running on an XboxOne
/// </summary>
public static bool IsXbox()
{
    if (deviceFamily == null)
        deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;

    return deviceFamily == "Windows.Xbox";
}

Immediately after public App()

And then the top of OnLaunched() should look like this:

/// <summary>
/// Invoked when the application is launched normally by the end user.  Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{

    // By default we want to fill the entire core window.
    ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);

#if DEBUG
    if (System.Diagnostics.Debugger.IsAttached)
    {
        this.DebugSettings.EnableFrameRateCounter = true;
    }
#endif
...
}

Just after that #endif ' you should see 'Frame rootFrame = Window.Current.Content as Frame;....

An additional thing to add:

Add this to public Game1()
_graphics.IsFullScreen = true;

And viola, that’s the full screen template fixed.

Also the XAML pages simply show:

xmlns:local="using:UwpGame">

All the time, this is App.xaml

And the same in GamePage.xaml, it does not appear to cause any issues and I can manually correct it but, um it might fail validation and cause page change issues? I think I noticed this work half the time that it would state the project name, so something is broken somewhere, wish I knew how to fix it but right now, VS hookups are not my scene.

EDIT

Also to note, max 17763 and min 14393 target platforms are required.

Update to this from the original post:

Windows 10 SDK 10.0.18362.0

Is the SDK you need at present.

So, I hope someone finds this useful and avoids the headache I had for days while trying to get this working only to discover the template got broken… so, I reverted to an older working project to check line by line and found the missing components.

The original post that this thread is a refresh of:

1 Like

OK, so, back to square one… :roll_eyes:

I am having the same issue, and using the fixes above, now it is just making no difference…

My once working project, also fails to work :frowning_face_with_open_mouth:

Does anyone have a solution for this that works for them?

EDIT

I removed the debugger attached code and it centered on the screen…

oh nvm I removed the core window part…

Still need to resolve this now :frowning:

I updated the targets:

image

15063 is the lowest functioning choice at present.

Hmm…

Screenshot_2021-10-29_05-12-28

Getting somewhere…

back buffer and hardware status shows:

1920
1080
Normal

EDIT

I thought to test the CoreApp, and this was the result out of the box:

[CoreApp]

Will see what it is doing differently and see if I can find any code differences…

Literally no code difference…

I seem to have fixed it with this combination:

image

[XAMLApp]

Time to keep coding!

EDIT

I isolated the fix to:

Add the following to your Initialise method:

_graphics.PreferredBackBufferWidth = 1920;
_graphics.PreferredBackBufferHeight = 1080;
_graphics.ApplyChanges();

EDIT

Works with the default [current] settings:

image

1 Like

Hmmm, so does your final entry fix the problem and if so, what happens with a target version higher than you have here?

Also, it seems this is something that affects MonoGame+Xaml only, so are you actually using Xaml as part of your app or could you go without Xaml (which would also improve performance?), or is there a problem there also?

If you refuse to read a post, and then make speculations on questions answered in the post…

Huh?

Read the post, or did you mean the entire post? final entry to me translated as the last EDIT, the answer is in the last post.

Read the post, but I see where the confusion is, though I did clarify it in the last post.

To expand on your latter question, Using XAML enables me to use the video player, as well as HTML pages, and more.

Performance is up to the developer.

If you are coding your entire UI in-engine, then go for Core, if you want the added functionality XAML brings, go for that, I am yet to discover what happens with XBOX game submissions, I know you cannot use the share charm feature, so, I am yet to see if I can use XAML for XBOX Game submissions, however I am going to test this with a sample app deployment to the store.

Just rechecked my apps on the store, I omitted them all from XBOX, so, I still need to experiment with it in the near future.

Let me know if you need further details on specifics.

Thank you for the clarifications, that’s helpful indeed.

I’m sorry if I’m being a bit thick but I’m still unclear on the Target Version part however. I mean from what you’ve written it looks like you’re saying there is a window scaling issue for MonoGame+Xaml on Xbox with any Target Version > Build 18362. Or perhaps it was the TargetVersion = Windows 11->Anything that was the problem?

Basically, you require a certain minimum target version for compatibility, if you try an older target, you will come across the error message that will explain it.

Just take the mention as a, try this if you have a certain issue.

EDIT

Also, previously, the targets fixed the Fullscreen issue for me but that has changed since, could have been a fluke too.