maui: [Windows] On .NET MAUI 9.0 Preview 4, a modal full screen window is not properly maximized

Description

On Windows in 9.0 Preview 4, a modal full screen window produced with

#if WINDOWS
            .ConfigureLifecycleEvents(events =>
            {
                // Make sure to add "using Microsoft.Maui.LifecycleEvents;" in the top of the file 
                events.AddWindows(windowsLifecycleBuilder =>
                {
                    windowsLifecycleBuilder.OnWindowCreated(window =>
                    {
                        window.ExtendsContentIntoTitleBar = false;
                        var handle = WinRT.Interop.WindowNative.GetWindowHandle(window);
                        var id = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(handle);
                        var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(id);
                        switch (appWindow.Presenter)
                        {
                            case Microsoft.UI.Windowing.OverlappedPresenter overlappedPresenter:
                                overlappedPresenter.SetBorderAndTitleBar(false, false);
                                overlappedPresenter.Maximize();
                                break;
                        }
                    });
                });
            })
#endif            

does not fully maximize itself, but leaves a blank space for where the title bar should be. Non-modal windows seem to work fine. The modal window is shown using the following code:

            var gamePage = new GamePage(this);
            await App.Current.MainPage.Navigation.PushModalAsync(gamePage);

Screenshot 2024-06-02 224231

Steps to Reproduce

  1. Make the default MAUI app
  2. Create a new MAUI ContentPage named ModalTestPage.
  3. Change ModalTestPage’s background color to Beige by adding to the page’s XAML: BackgroundColor="Beige" .
  4. Add the following code to the MainPage button:
            var modalPage = new ModalTestPage();
            Navigation.PushModalAsync(modalPage);
  1. Add to the top of MauiProgram.cs the following:

using Microsoft.Maui.LifecycleEvents;

and add to builder the following:

#if WINDOWS
                .ConfigureLifecycleEvents(events =>
                {
                    // Make sure to add "using Microsoft.Maui.LifecycleEvents;" in the top of the file 
                    events.AddWindows(windowsLifecycleBuilder =>
                    {
                        windowsLifecycleBuilder.OnWindowCreated(window =>
                        {
                            window.ExtendsContentIntoTitleBar = false;
                            var handle = WinRT.Interop.WindowNative.GetWindowHandle(window);
                            var id = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(handle);
                            var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(id);
                            switch (appWindow.Presenter)
                            {
                                case Microsoft.UI.Windowing.OverlappedPresenter overlappedPresenter:
                                    overlappedPresenter.SetBorderAndTitleBar(false, false);
                                    overlappedPresenter.Maximize();
                                    break;
                            }
                        });
                    });
                })
#endif            
  1. Build and start the app.
  2. Press the button.
  3. The modal page (beige) does not cover the whole window: Top still shows the main page underneath (white, with Home text):

Screenshot 2024-06-08 202445

Link to public reproduction project repository

https://github.com/hyvanmielenpelit/WindowsFullScreenModalPageSizeBug

Version with bug

9.0.0-preview.4.10690

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 11

Did you find any workaround?

No.

Relevant log output

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 39 (18 by maintainers)

Most upvoted comments

I tried the latest option and I can see:

Image

So it appears it’s not fixed.