Skip to content

WindowPersistence does not restore FullScreen presenter #253

@riyasy

Description

@riyasy

WinUIEx: 2.9.0
OS: Windows 11 x64
Platform: WinUI 3 (C#)

If the app is closed while the window state is in AppWindowPresenterKind.FullScreen, on next launch the window opens monitor-sized but in Overlapped (restored) state (rounded corners + maximize button).

It appears that WindowManager.PersistenceId restores size/position but not the presenter kind.

Is this by design? Would it make sense to optionally persist and restore AppWindowPresenterKind as well?

I can handle it manually, just checking whether this is expected behavior.

Thanks!

Note - In test code, while in FullScren, there is no close button, I closed by pressing Alt + F4

using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using WinUIEx;

namespace FullScreenTest;

public sealed partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        FullScreenButton.Click += MaximizeFullScreenToggle;
        var manager = WindowManager.Get(this);
        manager.PersistenceId = "FullScreenTest";
    }

    private void MaximizeFullScreenToggle(object sender, RoutedEventArgs e)
    {
        // Use .Kind (a plain enum) instead of `is OverlappedPresenter` / `is FullScreenPresenter`
        // type-pattern checks. The `is T` form goes through WinRT COM QueryInterface, which the
        // Release-build trimmer strips — causing the check to silently return false in Release.
        if (AppWindow.Presenter.Kind == AppWindowPresenterKind.Overlapped)
            AppWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
        else if (AppWindow.Presenter.Kind == AppWindowPresenterKind.FullScreen)
            AppWindow.SetPresenter(AppWindowPresenterKind.Overlapped);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions