I am new to WinUI and struggling to do some basic things in that. Any help is appreciated.
1.) Is there any way to show or hide default icon from the title bar in WinUI 3. I tried to set the null in this.SetIcon(null). But the default icon is still showing in the Title Bar.
2.) When using the ExtendsContentsIntoTitleBar = true, Is there any way to hide the Minimize and Maximize buttons. Even if I use the WinUIEx extensions method, like this.SetIsMinimizable(false); or this.SetIsMaximizable(false); These are not working as expected and minimize/maximize button is still showing.
There is a way to hide the maximize / minimize buttons and the icon.
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;
}
}