You are not trying to hide anything. The Window
is not yet shown, so hiding it has no effect. Also, hiding is not closing. If, by some reason, you see some window (except
) which is still showing, this is some other window, which has nothing to do with invisible window
, maybe you real main window.
By the way, if a window class is called
, it does not mean it is really main. The main window is the one used as a parameter of
If create your WPF application is a "usual" way, through the Visual Studio template, this call to
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
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