Reputation: 1590
I'm working on a small project where I have a login window and when the user is autheticated it will open a new window, that works but after the user logged in I want to close the Login window how ever, the main window doesn't close.
MainWindow mainWindow = new MainWindow();
mainWindow.Close();
Loader loader = new Loader();
loader.Show();
Upvotes: 0
Views: 110
Reputation: 42
You are initializing a new instance of a Window and close it immediateley afterwards.
It looks like your mainWindow
is not the login window you want to close. If you want to close the current Main Window of you application, you can use:
App.Current.MainWindow.Close();
Make sure you also set a new Main Window. I assume you wanted to do something similar to this, also assuming "loader" is your new Window:
private void Login(){
App.Current.MainWindow.Close();
Loader loader = new Loader();
App.Current.MainWindow = loader;
}
Upvotes: 1