Repository navigation
Description
Description
We made now an in-depth investigation in .NET 10.0.71 of the root causes of the issue that has been there since .NET 9 (see #27824). We can confirm that the Better Workaround below fixes the issue. Proposed fix below still needs to be tested, as it modifies MAUI itself, which we have not tested.
On Windows, when the application enters full-screen mode via AppWindowPresenterKind.FullScreen (set in MauiProgram.cs using ConfigureLifecycleEvents / OnWindowCreated) and a modal page is pushed via Navigation.PushModalAsync(), there is a 32-pixel tall gap at the very top of the modal page where the underlying page is visible. This gap corresponds to the Windows title bar height.
Additionally, even when applying a Margin = new Thickness(0, -32, 0, 0) workaround to visually cover the gap, the top ~32 pixels remain unclickable with a mouse — clicks in that region are intercepted by the WinUI non-client title bar area instead of reaching the modal page content.
Expected behavior: The modal page should cover the entire window content area, including the title bar region, with no visual gap and no unclickable areas.
Actual behavior: A 32px strip at the top of the modal page shows the page underneath, and that region does not respond to mouse/pointer input.
The bug is caused by the NavigationRootManager constructor unconditionally reserving title bar space for every page, including modal pages that should cover the full window.
When a modal page is pushed in ModalNavigationManager.Windows.cs, a new scoped MauiContext is created with a new NavigationRootManager:
var modalContext = WindowMauiContext.MakeScoped(registerNewNavigationRoot: true);The NavigationRootManager constructor (src/Core/src/Platform/Windows/NavigationRootManager.cs, line 15-27) creates a new WindowRootView and calls:
SetTitleBarVisibility(titleBar.ExtendsContentIntoTitleBar);Since ExtendsContentIntoTitleBar is true by default (set in MauiWinUIWindow constructor), this calls UpdateAppTitleBar(32, true, margins) on the modal's WindowRootView, which pushes the content down by 32px via:
var contentMargin = new WThickness(0, _appTitleBarHeight, 0, 0); // (0, 32, 0, 0)
this.SetApplicationResource("NavigationViewContentMargin", contentMargin);The code in ModalNavigationManager.Windows.cs correctly hides the title bar on the previous page (line 107-116) but does not hide it on the modal's own WindowRootView. The modal page therefore has its own 32px title bar reservation that should not exist.
The unclickable area is caused by the WinUI AppWindow.TitleBar non-client region remaining active at the OS level. The InputNonClientPointerSource regions are not cleared/adjusted for the modal page scenario.
Proposed Fix
In src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.Windows.cs, after obtaining the modal's NavigationRootManager, suppress the title bar on the modal's WindowRootView:
var windowManager = modalContext.GetNavigationRootManager();
if (windowManager is not null)
{
+ // Only remove the 32px title bar reservation if the app is in full-screen mode.
+ // In windowed mode, the reservation is required to prevent the modal's content
+ // from overlapping the OS window controls and to preserve the window drag region.
+ var appWindow = previousPage?.GetParentWindow()?.Handler?.PlatformView as Microsoft.UI.Xaml.Window;
+ var presenter = appWindow?.GetAppWindow()?.Presenter;
+ if (presenter is not null && presenter.Kind == Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen)
+ {
+ windowManager.SetTitleBarVisibility(false);
+ }
+
// Set the titlebar on the new navigation root
if (previousPage is not null &&
previousPage.GetParentWindow() is Window window &&
window.TitleBar is TitleBar titlebar)
{
windowManager.SetTitleBar(titlebar, modalContext);
}This calls SetTitleBarVisibility(false) which sets appbarHeight = 0, collapses the title bar container, and sets NavigationViewContentMargin to (0, 0, 0, 0) — eliminating the 32px gap. It also clears the InputNonClientPointerSource passthrough regions via UpdateTitleBarContentSize(), which fixes the unclickable area.
Note: If the modal page has an explicit Window.TitleBar set, the subsequent windowManager.SetTitleBar(titlebar, modalContext) call will re-enable and properly configure the title bar, so the fix does not break that scenario.
Steps to Reproduce
- Create a new File > New .NET MAUI App targeting Windows
- Replace
MauiProgram.csto enter full-screen mode on startup:
using Microsoft.Extensions.Logging;
using Microsoft.Maui.LifecycleEvents;
#if WINDOWS
using Microsoft.UI.Windowing;
#endif
namespace ModalBugRepro;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
#if WINDOWS
.ConfigureLifecycleEvents(events =>
{
events.AddWindows(windowsLifecycleBuilder =>
{
windowsLifecycleBuilder.OnWindowCreated(window =>
{
// Go full-screen
window.AppWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
});
});
})
#endif
;
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}- Replace
MainPage.xamlwith a page that has a bright background (e.g., blue), no navigation bar, and a button to push a modal:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ModalBugRepro.MainPage"
Shell.NavBarIsVisible="False"
BackgroundColor="Blue">
<VerticalStackLayout Spacing="20" VerticalOptions="Center">
<Label Text="This is the MAIN PAGE (Blue)"
FontSize="24"
HorizontalOptions="Center"
TextColor="White" />
<Button Text="Push Modal Page"
Clicked="OnPushModalClicked"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>- Create
ModalPage.xamlwith a contrasting background (e.g., red) and a button near the top edge - In
MainPage.xaml.cs, push the modal:await Navigation.PushModalAsync(new ModalPage()); - Run the app on Windows — it will enter full-screen automatically
- Click "Push Modal Page"
- Observe the blue strip at the very top of the window — the main page is visible through a ~32px gap
- Try clicking near the very top of the modal page — mouse clicks are not registered
Expected outcome: The red modal page covers the entire window; all areas are clickable.
Actual outcome: A ~32px blue strip from the main page is visible at the top; the top area does not respond to clicks.
Link to public reproduction project repository
https://github.com/hyvanmielenpelit/maui-modal-32px-gap-repro
Version with bug
10.0.70
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 (all versions)
Did you find any workaround?
Partial workaround (visual gap only)
Applying a negative top margin to the modal page covers the visual gap, but does not fix the unclickable area:
// In the modal page constructor
Margin = new Thickness(0, -32, 0, 0);Better workaround (fixes both issues)
A more complete workaround that fixes both the visual gap and the unclickable area by perfectly mimicking the actual framework fix. It uses Reflection to find the modal page's internal NavigationRootManager and tells it not to reserve title bar space:
protected override void OnAppearing()
{
base.OnAppearing();
#if WINDOWS
// Defer to ensure the modal's MAUI context is fully set up
Dispatcher.Dispatch(() =>
{
var mauiContext = this.Handler?.MauiContext;
if (mauiContext is null)
return;
// Get the NavigationRootManager for this modal's scoped context
var navManager = mauiContext.Services.GetService(
typeof(Microsoft.Maui.Platform.NavigationRootManager));
if (navManager is not null)
{
var window = this.GetParentWindow()?.Handler?.PlatformView as Microsoft.UI.Xaml.Window;
if (window is not null)
{
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hwnd);
var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
// ONLY apply the fix in full-screen mode. In windowed mode, the 32px
// reservation is required to avoid overlapping the OS window controls
// and to preserve the window drag region.
if (appWindow?.Presenter?.Kind == Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen)
{
// Invoke internal void SetTitleBarVisibility(bool isVisible)
var method = navManager.GetType().GetMethod(
"SetTitleBarVisibility",
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Public);
if (method is not null)
{
// Passing false tells it to collapse the title bar, zero the 32px margin,
// and clear the unclickable non-client input regions.
method.Invoke(navManager, new object[] { false });
}
}
}
}
});
#endif
}Note: Because this calls the framework's own internal method (
SetTitleBarVisibility), it automatically handles zeroing the margins, collapsing the title bar container, refreshing the theme resources, and clearing the non-client input regions all at once.
Activity
LogishaSelvarajSF4525 commentedon Jun 22, 2026
This issue has been validated in Visual Studio 18.7.0 with .NET MAUI versions 9.0.0, 10.0.70 and 10.0.71. It was reproducible on Windows platform. I have attached the output & video reference below:

Bug 1:
Bug 2: After applying bug 1 workaround, bug 2 occurs
Screen.Recording.2026-06-22.163146.mp4
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
11 remaining items
Publish reproduction evidence for #36040 on windows
Publish reproduction evidence for #36040 on windows
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…
[Windows] Fix Modal page has a 32px title bar gap at the top in full-…