If the user logs on successfully, then I want to show the main window, if not, I want to exit the application
Solution 1:
I think I figured out what I was trying to do.
1) I needed to set the "StartupUri" in the App.xaml to "Logon.xaml", where Logon.xaml is my logon window.
2) in the LogonButton_Click event handler, I added the following
if (blnAuthenticateSuccessful) {
MainWindow main = new MainWindow();
App.Current.MainWindow = main;
this.Close();
main.Show();
}
This seems to accomplish what I want.
Solution 2:
If you wanted a new window to appear to allow the user to enter their login information, then I have added some code below. However, creating a true Modal Dialog box is a bit more complicated in WPF so I haven't explained it here. There is information about modal dialog boxes in WPF here: http://msdn.microsoft.com/en-us/library/aa969773.aspx
From the MainWindow you can open the login window and hide the main window with this:
// Code for MainWindow
// Create a new instance of the login window and then show it
LoginWindow loginWindow = new LoginWindow();
loginWindow.Show();
// Hide the MainWindow until later
this.Hide();
Then use this on the login page to show the main window again once the user has logged in:
// Code for Login window
// This code finds the main window again and shows it
Application.Current.MainWindow.Show();