I am creating an application using the DockPanel for my layout. In the ‘Left’ DockPanel I have setup a few links (Labels) that I would like to use to open different UserControls when a link is clicked. I want the UserControls to always open in the ‘Right’ DockPanel when the appropriate link is clicked.
What mechanism in WPF (using MVVM) would I use to accomplish this? Are there any examples that I can view?
The general pattern to follow is this:
ContentPresenterto the place in your user interface which will host the switch-able content (the right panel of theDockPanelin your case).Contentproperty of theContentPresenterto a property in your view model that is of a viewModel type that represents the view E.G.BoundContent.PropertyChangedevent to notify your view.DataTemplatethat maps each user control to each viewModel.Rachel Lims blog contains a couple of examples which demonstrates the above: