小编Bil*_*obs的帖子

如何在WinUI3中将默认窗口模式设置为全屏?

namespace MyApp
{
    public sealed partial class MainWindow : Window
    {
        AppWindow m_appWindow;
        
        public MainWindow()
        {
            this.InitializeComponent();
            m_appWindow = GetAppWindowForCurrentWindow();
        }
               
        private AppWindow GetAppWindowForCurrentWindow()
        {
            IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
            WindowId myWndId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
                    
            return AppWindow.GetFromWindowId(myWndId);
        }

        private void SwitchPresenter_FullScreen(object sender, RoutedEventArgs e)
        {
            m_appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
        }  
    }
}
Run Code Online (Sandbox Code Playgroud)

SwitchPresenter_FullScreen 功能有效,但如何将应用程序的默认窗口模式设置为全屏?我可以在应用程序启动时调用 SwitchPresenter_FullScreen 吗?

c# windows winui winui-3

1
推荐指数
1
解决办法
1616
查看次数

标签 统计

c# ×1

windows ×1

winui ×1

winui-3 ×1