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
It looks like something I ran into when I created a second window to act as a dialog box. When the second window was opened and then closed and then the main window was closed, the app kept running (in the background). I added (or confirmed) the following in my App.xaml:
No joy.
So, I finally went into my "MainWindow.xaml" and added a "Closed" property to the Window which went to a "MainWind_Closed" method that looks like the following:
private void MainWind_Closed(object sender, EventArgs e)
{
foreach ( Window w in App.Current.Windows )
{
if (w.DataContext != this)
w.Close();
}
}
Running through the debugger, it looks like the only window that shows up is the window I created as a dialog--in other words, the foreach loop only finds one window--the dialog, not the main.
I had "this.Close()" running in the method that closed the dialog, and I had a "dlgwin.Close()" that came after the "dlgwin.ShowDialog()", and that didn't work. Not even a "dlgwin = null".
So, why wouldn't that dialog close without this extra stuff? Oh well. This works.