Create topmost fullscreen window without titlebar, but desktop's taskbar must be visible

I'm using WinUI3, and I need to create topmost fullscreen borderless window without titlebar, but taskbar must be visible. My window must be always on top, it should not hide when I press Win+D I tried to set AppWindow's Presenter to CompactOverlay and set size manually, but titlebar is visible. I tried to set AppWindow's Presenter to Fullscreen, but it hides taskbar, if i set size, window can be hidden. Example of window, which i need(My window is all gray area)

Upvotes: 0

Views: 345

Answers (1)

Andrew KeepCoding
Andrew KeepCoding

Reputation: 13666

This should work:

public sealed partial class MainWindow : Window
{
    public MainWindow()
    {
        this.InitializeComponent();

        _presenter = this.AppWindow.Presenter as OverlappedPresenter;
        this.Activated += MainWindow_Activated;
    }

    private OverlappedPresenter? _presenter;

    private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
    {
        if (_presenter is null)
        {
            return;
        }

        _presenter.Maximize();
        _presenter.SetBorderAndTitleBar(hasBorder: false, hasTitleBar: false);
        _presenter.IsAlwaysOnTop = true;
    }
}

Upvotes: 5

Related Questions