Wednesday, October 5, 2016

WPF: How do I set the Owner Window of a Dialog shown by a UserControl?

w.Owner = this;

w.Owner = Window.GetWindow(this);

To get the top level window your control is in, assuming there is one:

(Window)PresentationSource.FromVisual(this).RootVisual

To get the main window:

Application.Current.MainWindow

Reference:

http://stackoverflow.com/questions/607370/wpf-how-do-i-set-the-owner-window-of-a-dialog-shown-by-a-usercontrol

No comments: