How to do Regions in WPF without Prism?
Specifically in MVVM Light toolkit? I've not dove into the Prism code yet to see what i开发者_Go百科t does in regard to regions in a WPF UI. Seems like with the messaging and the ViewModelLocator in MVVM Light you could do a similar thing....Can you? Can anyone give some examples on how you could do this? Essentially I'd like to click on a button and load two different view models into the UI. Perhaps a better way to explain is Outlook-like Navigation Pane functionality.
This can be done fairly easily in WPF, without any framework.
Just setup a DataTemplate in your Application (or at the Window/UserControl level) that maps the ViewModel to the View you wish to display for that ViewModel.
You can then just use a ContentPresenter, and bind it's contents to a single property (which can be of type object
) within your ViewModel. When you want to set the "region" to a specific View, just set the property to the appropriate ViewModel, and WPF will automatically wire up everything for you.
精彩评论