Is there anyway to make a dialog window appear always on top of the parent window If you change the dialog windows ShowInTaskBar property to false and you switch applications and then switch back, your application becomes unusable. The parent window hides the dialog window and you effectively can't do anything anymore as you can't get to the dialog window.
I know there is a TopMost Property that I can set, but that makes the window the absolute top window (i.e. appear on top of every window open). How would I go about making the dialog window the topmost window relative to the parent window
Thanks,
Kevin

Modal Dialog Window Always Being TopMost Window Relative to the Parent Window
M M Mason
Quartzite
Thanks for the help Michael, but the answer is simpler than that. All you have to do is to make the dialog's Window Owner property point to the parent window that spawned it.
YourDialogClass dialog = new YourDialogClass ();dialog.Owner = TheParentWindow;
dialog.ShowDialog();
abhijeet.koli
I came up with the following, but it seems disturbigly difficult. And I have to wonder about that peculiar null return. Can anyone shed light on cases where that "null return" gets executed When would something in my Parent chain not be a FrameworkElement VisualParent looked promising, but it's a protected member, so it's not usable.
Window GetParentWindow(){
FrameworkElement element = this;
while (true)
{ if (element is Window)
return (Window)element;
DependencyObject o = element.Parent;
if (o is FrameworkElement)
{
element = (FrameworkElement)o;
}
else
{
return null;
}
}
}
And I'm guessing, on a hunch that it won't work too well in a click-once app... Surely click once apps must allow dialogs. No There must be a better way.
DaniMaia
hate to ask what is probably an obvious question....
But how exactly do you find TheParentWindow I must be missing something obvious here, but 17 layers down in a deeply nested element structure... with two UserControls between my and my main window, and I can't figure out how to walk a parent chain to find my TheParentWindow... .
And what if my topmost element isn't a Window..