The problem is: you cannot close main window without closing the application. For this reason,
Window.Hide
is used instead of closing. You can prevent closing the form by the user handling the event
Closing
or, better, overriding the method
OnClosing
. You can prevent "real" closing of the form by assigning
CancelEventArgs.Cancel
to
true
.
See
http://msdn.microsoft.com/en-us/library/system.windows.window.closing.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.window.onclosing.aspx[
^].
Generally, such design showing forms alternatively is not recommended. It's much better to use just one form showing different parts of it and hiding others. One of the nice forms of is is tabbed UI based on
TabControl
.
—SA