[英]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.