您好,
设置全屏或者隐藏标题栏
你可以在MauiProgram.cs中通过builder,设置全屏或者隐藏标题栏,关于正则表达式,你开了另外的链接,请跟随新的链接
#if WINDOWS
builder.ConfigureLifecycleEvents(events =>
{
events.AddWindows(wndLifeCycleBuilder =>
{
wndLifeCycleBuilder.OnWindowCreated(window =>
{
window.ExtendsContentIntoTitleBar = false; /*This is important to prevent your app content extends into the title bar area.*/
IntPtr nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
WindowId win32WindowsId = Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
Microsoft.UI.Windowing.AppWindow winuiAppWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(win32WindowsId);
if(winuiAppWindow.Presenter is OverlappedPresenter p)
{
//隐藏titlebar
p.SetBorderAndTitleBar(false, false);
//设置全屏
winuiAppWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
}
});
});
});
#endif
同时,这些代码仅仅作用于windows 平台,使用的namespace 也需要条件编译进行包裹
#if WINDOWS
using Microsoft.Maui.LifecycleEvents;
using Microsoft.UI;
using Microsoft.UI.Windowing;
#endif
如果答案是正确的,请点击“接受答案”并点赞。 如果您对此答案还有其他疑问,请点击“评论”。
注意:如果您想接收相关电子邮件,请按照我们的文档中的步骤启用电子邮件通知 此线程的通知。