When a user has entered a correct password, a login window should close and the main window should open. I would like to do this from the ViewModel, however, the ViewModel may not know anything about the view.
I've searched a lot and apparantly the best way is to use the mediator pattern. I understand how this pattern works, but how to effectivly use it in this case?
the mediator will need:
- A reference to the View
- A reference to the ViewModel
The ViewModel will need a reference to the mediator.
Where do I need to create the mediator? I can't do it in the ViewModel as I won't be able to set the reference to the view. Creating the mediator in the view is an option as I can get the ViewModel out of the DataContext property, but then I will still need to pass the mediator to the ViewModel, which will only make the code more difficult.
How do I properly use a mediator for opening/closing windows?