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);
Steps to Reproduce
- Make the default MAUI app
- Create a new MAUI ContentPage named ModalTestPage.
- Change ModalTestPage’s background color to Beige by adding to the page’s XAML:
BackgroundColor="Beige". - Add the following code to the MainPage button:
var modalPage = new ModalTestPage();
Navigation.PushModalAsync(modalPage);
- 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
- Build and start the app.
- Press the button.
- The modal page (beige) does not cover the whole window: Top still shows the main page underneath (white, with Home text):
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)
I tried the latest option and I can see:
So it appears it’s not fixed.
Ok, here you go: https://github.com/hyvanmielenpelit/WindowsFullScreenModalPageSizeBug