- I’m coding a windows form using WPF, XAML, C#.
- I have a Frame object created in MainWindow.xaml, and the frame
points to Login.xaml. - Login.xaml handles a login operation for a user and the logic for
this is stored in Login.xaml.cs.
How can I get Login.xaml to communicate with the code in MainWindow.xaml.cs so that it can change the frame once a user logs in?
Communicate through view models using events. Or look for some event aggregator to eliminate coupling between the view models.
MainWindowViewModelwill instantiateLoginViewModel, display theLogincontrol and register an event OnLoggedIn and on successful login it will switch to another frame/screen.