I want to navigate from one view to another view in WPF using MVVM. How can I do this? Please let me know the procedure.
Thanks, Prashant
I want to navigate from one view to another view in WPF using MVVM. How can I do this? Please let me know the procedure.
Thanks, Prashant
You would simply create your new view, assign it's view model, and then Navigate to it:
this.NavigationService.Navigate(new SomeOtherView { ViewModel = someViewModel }, null);
'Navigate' is a bit vague, but when I have a 'screen-based' application with content hosted in a particular section of a larger window (with say button-based navigation controls and status surrounding the content area), I like using a MainViewModel, with an ActiveScreen property of type Object and a ContentPresenter bound to ActiveScreen. I'll define DataTemplates that bind the various ViewModel instances to the appropriate View control and simply instantiate or select from different ViewModels for the ActiveScreen. The binding system takes care of the actual instantiation of the View instances.