tags:

views:

31

answers:

1

what am I missing having this code behind on a XAML window

// Create a window and make this window its owner Window ownedWindow = new Window(); ownedWindow.Owner = this; ownedWindow.ShowDialog();

I don't see the behavior http://msdn.microsoft.com/en-us/library/system.windows.window.owner.aspx

Once this relationship is established, the following behaviors are exhibited:

•If an owner window is minimized, all its owned windows are minimized as well.

•If an owned window is minimized, its owner is not minimized.

•If an owner window is maximized, both the owner window and its owned windows are restored.

•An owner window can never cover an owned window.

•Owned windows that were not opened using ShowDialog are not modal. The user can still interact with the owner window.

•If you close an owner window, its owned windows are also closed.

•If an owned window was opened by its owner window using Show, and the owner window is closed, the owned window's Closing event is not raised.

TIA

+1  A: 

The ShowDialog() method shows the window as a modal dialog, overriding most of this behavior.

You should call Show() instead to show the window as a child window.
Note that Show() is not a blocking call; your next line of code will execute immediately, not after the window is closed.

SLaks
Thanks SLaks what about http://msdn.microsoft.com/en-us/library/system.windows.window.owner.aspxWhen you open a child window by calling ShowDialog, you should also set the Owner property of the child window.
ramnz
@ramnz: What? If you want a modal dialog, call `ShowDialog()`. If you don't, call `Show`.
SLaks