This can be achieved by setting SetBorderAndTitleBar(Boolean, Boolean)
to false
and then set ExtendsContentIntoTitleBar
to false
. Please use the MauiProgram.cs
like below:
using MauiApp13blazor.Data;
using Microsoft.Maui.LifecycleEvents;
#if WINDOWS
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Windows.Graphics;
#endif
namespace MauiApp13blazor;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
})
.ConfigureLifecycleEvents(events =>
{
#if WINDOWS
events.AddWindows(wndLifeCycleBuilder =>
{
wndLifeCycleBuilder.OnWindowCreated(window =>
{
IntPtr nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
WindowId nativeWindowId = Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
AppWindow appWindow = AppWindow.GetFromWindowId(nativeWindowId);
var p = appWindow.Presenter as OverlappedPresenter;
window.ExtendsContentIntoTitleBar = false;
p.SetBorderAndTitleBar(false, false);
});
});
#endif
});
builder.Services.AddMauiBlazorWebView();
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();
#endif
builder.Services.AddSingleton<WeatherForecastService>();
return builder.Build();
}
}