如何為面向 Windows 的 MAUI Blazor 應用程式設定視窗標題?

在 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