I am running into a problem in a WPF/C# application while minimizing it, I have looked online and the most popular solution to Minimizing Window is to change the Mainwindow state to Minimize, and this is also what I have been doing
private void Minmize(object sender, RoutedEventArgs e)
{
Application.Current.MainWindow.WindowState = WindowState.Minimized;
}
This works for me fine If its from a window which is initialized as the startup URI of the Application, simply put the 'Minimize' event fired will only work if the button that triggers the event "Minimize" is part of the Window that is Started when you run the Application
So In my Case there is a login Window Before, when the Application Runs the Login Window appears and Login Details are Entered, upon Successful Login This is the Code I run
private void nxtwin_Click(object sender, RoutedEventArgs e)
{
new MainWindow().Show();
this.Close();
}
SO naturally It shows MainWindow, But now the Minimize Code Doesn't Work
Might be Relevant
Now I do not know if this is related but I have My Debug bar enabled (The Black bar at the top of the application for debugging), so it initially the Debug bar loads fine, But Once I have Fired the Minimize Event, except Everything Else The Debug Bar, Minimizes!! (how do I know it minimizes and not just hide or if the visibility is changed to collapsed or hidden bcz it plays the Minimize animation before Disappearing and then never comes back )