I have a WPF application where I have two windows. First window is just a login window for users. So whenever the user successfully logs in, 2nd window appears. To normally shut down the complete application, user will press the red cross button and I have included this event in my code as below:
/* Shut Down the application when user clicks red cross button*/
void Window_Closing(object sender, CancelEventArgs e)
{
System.Windows.Application curApp = System.Windows.Application.Current;
curApp.Shutdown();
}
So the above code completly shut down the application. But let say, if user do not want to login and simply wants to close the application while he is in the 1st window (login window). In that case, application should also shut down. So I included the above same code for the red cross button of the 1st login window. But that created another problem, because the next time any user logs in, I am closing the 1st window and calling the 2nd window. In this scenairo, application completely shuts down because of window closing event of 1st window.
How can I handle this condition.?