1

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

Joel B Fant
  • 24,406
  • 4
  • 66
  • 67
user761276
  • 11
  • 1
  • You are going to have to give us more information here - what does your application look like? What is the architecture right now? Are these views in a docking framework? New windows? Is this a WPF Navigation app? – ColinE May 19 '11 at 14:56

2 Answers2

1

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);
Tejs
  • 40,736
  • 10
  • 68
  • 86
1

'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.

Dan Bryant
  • 27,329
  • 4
  • 56
  • 102