Created
February 13, 2023 12:45
-
-
Save jfversluis/3aaac48322c995159359a22805781b52 to your computer and use it in GitHub Desktop.
Set .NET MAUI Window as fullscreen on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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