Mon application MVVM a démarré avec App.xaml.csMVVM - comment afficher la vue?
Ici, je crée une fenêtre principale. Il a un cadre. Ici, je mets LoginView.
Il a le bouton "Connexion". J'ai une commande qui vérifie et se connecte.
Ce code que j'ai dans LoginViewModel. Si tout va bien - je devrais montrer la vue suivante. Comment je peux le faire?
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
}
}
Comment et où j'afficher toutes les vues nécessaires? I Utilisez maintenant WPF MVVM Toolkit.