I\'m used to WinForms programming in Visual Studio, but I wanted to give WPF a try.
I added another window to my project, called Window01. The main window is called
Because the default shutdown mode in a WPF application is OnLastWindowClose, which means the application stops when the last window closes.
When you instantiate a new Window object, it automatically gets added to the list of windows in the application. So, the problem was that your application was creating two windows when it started - the MainWindow and the not-yet-shown Window01 - and if you only closed the MainWindow, the Window01 would keep your application running.
Normally, you will create a window object in the same method that is going to call its ShowDialog, and you will create a new window object each time the dialog is shown.