如何为面向 Windows 的 MAUI Blazor 应用程序设置窗口标题?
原文链接 [https://www.cnblogs.com/densen2014/p/16946311.html]
在 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!";
}
关联项目
FreeSql QQ群:4336577
BA & Blazor QQ群:795206915
Maui Blazor 中文社区 QQ群:645660665
知识共享许可协议
本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。欢迎转载、使用、重新发布,但务必保留文章署名AlexChow(包含链接: https://github.com/densen2014 ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请与我联系 。
转载声明
本文来自博客园,作者:周创琳 AlexChow,转载请注明原文链接:https://www.cnblogs.com/densen2014/p/16946311.html
AlexChow
今日头条 | 博客园 | 知乎 | Gitee | GitHub