WinUI 3标题栏自定义



我是WinUI的新手,正在努力做一些基本的事情。如有任何帮助,不胜感激。

1)。是否有任何方法显示或隐藏默认图标从标题栏在WinUI 3。我试图在this.SetIcon(null)中设置null。但是默认的图标仍然显示在标题栏。

2)。当使用ExtendsContentsIntoTitleBar = true时,是否有任何方法可以隐藏最小化和最大化按钮。即使我使用winux扩展方法,就像this.SetIsMinimizable(假);或this.SetIsMaximizable(假);这些没有像预期的那样工作,最小化/最大化按钮仍在显示。

可以隐藏最大化/最小化按钮和图标。

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;
}
}

最新更新