How to close/hide app main window?

Viewed 1060

I have an app that has a main window and secondary windows.

In certain situations, I would like to only display a secondary window when the user launches the app.

The problem is that the app's main window is automatically launched, so I after programamtically opening the secondary window I am left with both the main and secondary windows.

Is there any way I can hide the main window? (Ie, emulate the user pressing the "close button" in the top right corner of the main window?)

3 Answers

Execute ApplicationView.GetForCurrentView().TryConsolidateAsync() in main window to close it properly as if you have closed it by clicking close button in title bar. This is preferred over Application.Exit() as this method suspends the app while Application.Exit() closes app abruptly. Also closing app by this method your app's previous position and size is remembered unlike for Application.Exit().

Related