My MVVM application started with App.xaml.cs
Here I create a main window. It has frame. Here I put LoginView.
It has button "Login". I have command, which checks and do login.
This code I have in LoginViewModel. If all ok - I should show the next View. How I can do it?
App.xaml.cs
private void OnStartup(object sender, StartupEventArgs e)
{
LoginViewModel loginVM = new LoginViewModel();
MainView mainView = new MainView();
LoginView loginView = new LoginView();
loginView.DataContext = loginVM;
mainView.Frame.Content = loginView;
mainView.Show();
}
LoginViewModel.cs
// this method calls by binding after Click Login in LoginView
private void Login()
{
//TODO: Realize it
if (LoginModel.Login("User1", "Password"))
{
// HERE I SHOULD CLOSE LOGINVIEW AND SHOW NEXT VIEW
}
}
How and where I should show all necessary views? I Use now WPF MVVM Toolkit.