自定义标题栏
可见微软文档标题栏自定义 (opens new window)
按照WinUI3
的教程走就行
// MainPage.cs
IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow);
//如果在App.cs文件里则将App.MainWindow改为MainWindow
Microsoft.UI.WindowId myWndId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
Microsoft.UI.Windowing.AppWindow? appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(myWndId);
Microsoft.UI.Windowing.AppWindowTitleBar? titleBar = appWindow.TitleBar;
titleBar.ExtendsContentIntoTitleBar = true;
titleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent;
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
上次更新: 2023/08/24, 14:50:27