I am new to WPF and MVVM and am working on an application which has a few views. Right now I have a View(HomePageView) shown in the shellView's context. Now using a button in the HomePageView I want to load another View in place of the currently shown HomePageView. After looking it up on google, I found something about Event Aggregators. I would request someone to explain the implementation or direct to a good sample application.
To package content for navigation, WPF provides the Page class. You can navigate from one Page to another declaratively, by using a Hyperlink, or programmatically, by using the NavigationService. WPF uses the journal to remember pages that have been navigated from and to navigate back to them.
You can create One ViewModel for multiple views.
Navigation should always be handled in the ViewModel. You're on the right track with thinking that the perfect implementation of the MVVM design pattern would mean you could run your application entirely without Views, and you can't do that if your Views control your Navigation.
If your new to WPF MVVM I'd suggest first picking a decent helper tool
There are quite a few options. MVVM Light, Prism, MEF
I'd suggest MVVM light. Simple and easy to get up and running. Prism isnt solely a MVVM Helper but includes features to assist with MVVM. Not done much with MEF myself or things like Caliburn Micro.
As for a sample to explain how navigation between views work with MVVM Light try:
http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Views
MVVM Light on CodePlex:
http://mvvmlight.codeplex.com/
^^ link has forwards to some video presentations totally worth watching
Another nice sample using MVVM Light:
http://apuntanotas.codeplex.com/
These should help you get started and you always got https://stackoverflow.com/questions/tagged/wpf for particular questions :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With