原文链接 [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);

本文介绍如何在Microsoft MAUI应用程序中使用反射方法获取AppWindow实例,并设置窗口标题。通过在App.xaml.cs文件中实现特定代码,可以为运行在Windows平台上的MAUI应用设置自定义的窗口标题。
最低0.47元/天 解锁文章
957

被折叠的 条评论
为什么被折叠?



