MAUI 全屏时保留任务栏

2022年11月7日 1446点热度 1人点赞 0条评论
内容纲要

默认情况下,MAUI 全屏的时候,任务栏会被屏蔽掉。
参考解决方法:https://github.com/dotnet/maui/issues/5478

获取窗口对象:

                        IntPtr nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
                        WindowId win32WindowsId = Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
                        AppWindow winuiAppWindow = AppWindow.GetFromWindowId(win32WindowsId);

设置全屏时保留任务栏:

                        switch (winuiAppWindow.Presenter)
                        {
                            case OverlappedPresenter overlappedPresenter:
                                overlappedPresenter.SetBorderAndTitleBar(true, true);
                                overlappedPresenter.Maximize();
                                break;
                        }

主要是 SetBorderAndTitleBar。

痴者工良

高级程序员劝退师

文章评论