Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window.ShowDialog(owner) with minimized owner is not locking the owner correctly #18242

Open
ppaszkiewiczcom opened this issue Feb 18, 2025 · 0 comments
Labels

Comments

@ppaszkiewiczcom
Copy link

ppaszkiewiczcom commented Feb 18, 2025

Describe the bug

When using dialog.Show(owner) on owner with WindowState.Minimized the dialog will appear, however owner can be restored through task bar click (not through alt-tab) and interacted with freely which is unexpected.

To Reproduce

Create and dialog.Show(owner) on owner in minimized state - in my use case it manifested when trying to implement an "unsaved changes" warning (something like this):

    protected override void OnClosing(WindowClosingEventArgs e)
    {
        base.OnClosing(e);
        if (ViewModel.HasUnsavedChanges)
        {
            e.Cancel = true;
            Dispatcher.UIThread.Post(async () =>
            {
                var dialog = new UnsavedChangesDialog();
                await dialog.ShowDialog(this);
                if (dialog.Result == ...)
                {
                    // ...
                }
            });
        }
    }

With this code I minimize the main window and attempt to close it through task bar or by turning off the system to open the dialog.

While dialog is shown owner can be restored with taskbar click and freely used, disregarding the dialog.

Expected behavior

Owner window should remain locked as long as any OwnedWindows exist, regardless of when they appeared.

My current workaround is to force owner back into normal/fullsrceen state (that I have to keep track of) before any dialog is shown.

Avalonia version

11.2.4

OS

Windows

Additional context

System: Windows 10, 19045.5371
Theme: Fluent theme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant