Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Created February 13, 2023 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfversluis/3aaac48322c995159359a22805781b52 to your computer and use it in GitHub Desktop.
Save jfversluis/3aaac48322c995159359a22805781b52 to your computer and use it in GitHub Desktop.
Set .NET MAUI Window as fullscreen on Windows
#if WINDOWS
builder.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment