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

Setting IsVisible = false closes dialog instead of hiding #18006

Open
AnastassiaP opened this issue Jan 20, 2025 · 1 comment
Open

Setting IsVisible = false closes dialog instead of hiding #18006

AnastassiaP opened this issue Jan 20, 2025 · 1 comment
Labels

Comments

@AnastassiaP
Copy link

Describe the bug

Showing dialog and then setting its visibility to false closes the dialog window, then on calling ShowDialog again the following exception is received:

Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.InvalidOperationException: Cannot re-show a closed window.

To Reproduce

  1. create new dialog window:
    private DialogWindow dialogWindow = new DialogWindow();

  2. show dialog window
    dialogWindow.ShowDialog(this);

  3. set:
    IsVisible = false;

  4. re-show dialog
    dialogWindow.ShowDialog(this);

  5. Exception is thrown

Expected behavior

  1. Dialog window is not actually closed, but is just hidden
  2. No exception is thrown on dialog re-open

Avalonia version

11.2.3

OS

macOS, Windows, Linux

Additional context

as an alternative Hide() is hiding window as expected

@grokys
Copy link
Member

grokys commented Jan 22, 2025

This check causes setting IsVisible = false to close the window:

if (_showingAsDialog)
{
Close(false);
}

However Using Window.Hide() takes a completely different code path which doesn't have this check:

public override void Hide()

And it seems to work fine. I think the check in IsVisibleChanged can be removed.

There does seem to be another problem (at least on Windows) where hiding a modal window causes the parent window to be sent behind the previously activated application.

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

2 participants