首页 > 系统相关 >如何为面向 Windows 的 MAUI Blazor 应用程序设置窗口标题?

如何为面向 Windows 的 MAUI Blazor 应用程序设置窗口标题?

时间:2022-12-03 06:55:04浏览次数:58  
标签:Title Windows AppWindow UI MAUI using Blazor Microsoft

在 Platforms -> Windows 下的 App.xaml.cs 中,可以通过一些反射用法来检索 AppWindow。 然后可以在 appwindow 实例上设置 Title 属性。

In App.xaml.cs under Platforms -> Windows, the AppWindow can be retreived with some reflection usage. The Title property can then be set on the appwindow instance.

using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using WinRT.Interop;

        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            base.OnLaunched(args);
 
            var currentWindow = Application.Windows[0].Handler?.PlatformView;
            IntPtr _windowHandle = WindowNative.GetWindowHandle(currentWindow);
            var windowId = Win32Interop.GetWindowIdFromWindow(_windowHandle);

            AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
            appWindow.Title = "Title!";
        }

引用来源
https://stackoverflow.com/questions/70258689/how-to-set-window-title-for-a-maui-blazor-app-targeting-windows

标签:Title,Windows,AppWindow,UI,MAUI,using,Blazor,Microsoft
From: https://www.cnblogs.com/densen2014/p/16946311.html

相关文章