How to make regions in WPF without a prism?

In particular, in MVVM Light tools? I haven't hit Prism code yet to see what it does regarding regions in the WPF user interface. It looks like with the messaging and ViewModelLocator in MVVM Light you can do something like this ... Can you? Can someone give examples of how you could do this? In fact, I would like to click on the button and load two different presentation models into the user interface. Perhaps the best way to explain this is the navigation bar functionality, similar to Outlook.

+2
source share
1 answer

This can be done quite easily in WPF without any frameworks.

Just set up a DataTemplate in your application (or at the Window / UserControl level) that displays the ViewModel in the view that you want to display for that ViewModel.

Then you can simply use the ContentPresenter and bind its contents to a single property (which can be of type object ) in your ViewModel. When you want to set the "area" to a specific view, just set the property to the appropriate ViewModel, and WPF will automatically connect everything for you.

+4
source

All Articles