You are not trying to hide anything. The Window
mv
is not yet shown, so hiding it has no effect. Also, hiding is not closing. If, by some reason, you see some window (except
mw1
) which is still showing, this is some other window, which has nothing to do with invisible window
mv
, maybe you real main window.
By the way, if a window class is called
MainWindow
, it does not mean it is really main. The main window is the one used as a parameter of
Application.Run(Window)
,
http://msdn.microsoft.com/en-us/library/ms597011.aspx[
^].
If create your WPF application is a "usual" way, through the Visual Studio template, this call to
Application.Run
is auto-generated, so you may not see it, but it always exists in your application.
And please don't ask what should you do: you shouldn't do anything like what is written in your code; it just makes no sense. In particular, you should not close a main window, it would close the application.
One of the approaches it to call
Application.Run
several times, each time with a different window, but I don't think you really need it. You should better think on your application design.
—SA