[英]WinUI 3 Title Bar Customization
我是 WinUI 的新手,正在努力做一些基本的事情。 任何幫助表示贊賞。
1.) 有什么方法可以在 WinUI 3 的標題欄中顯示或隱藏默認圖標。我試圖在 this.SetIcon(null) 中設置 null。 但默認圖標仍顯示在標題欄中。
2.) 當使用 ExtendsContentsIntoTitleBar = true 時,有沒有辦法隱藏最小化和最大化按鈕。 即使我使用 WinUIEx 擴展方法,如 this.SetIsMinimizable(false); 或 this.SetIsMaximizable(false); 這些未按預期工作,最小化/最大化按鈕仍在顯示。
有一種方法可以隱藏最大化/最小化按鈕。 並且還可以隱藏圖標。
MainWindow.xaml.cs
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace WinUI3
{
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
GetAppWindowAndPresenter();
_presenter.IsMaximizable = false;
_presenter.IsMinimizable = false;
_apw.Title = "Title";
_apw.TitleBar.IconShowOptions = IconShowOptions.HideIconAndSystemMenu;
}
public void GetAppWindowAndPresenter()
{
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
WindowId myWndId = Win32Interop.GetWindowIdFromWindow(hWnd);
_apw = AppWindow.GetFromWindowId(myWndId);
_presenter = _apw.Presenter as OverlappedPresenter;
}
private AppWindow _apw;
private OverlappedPresenter _presenter;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.