Skip to content

Instantly share code, notes, and snippets.

@brunossn
Created May 3, 2019 14:33
Show Gist options
  • Save brunossn/8470a176bc6b78af60337fda77f60f4e to your computer and use it in GitHub Desktop.
Save brunossn/8470a176bc6b78af60337fda77f60f4e to your computer and use it in GitHub Desktop.
A Window.ShowDialog() overload method to set the onwer window.
public static class WindowExtension
{
public static bool? ShowDialog(this Window window, Window parentWindow)
{
window.Owner = parentWindow;
return window.ShowDialog();
}
}
@brunossn
Copy link
Author

brunossn commented May 3, 2019

How to use:

new MyWindow.ShowDialog(this);

Instead:

var frm = new MyWindow();
frm.Owner = this;
frm.ShowDialog();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment