Reputation: 2664
Using the MVVM pattern in WPF, is it best to use a 'master' ViewModel and only use that as your DataContext or is it okay to have multiple ViewModels that interact with the view (if that's possible)? Sorry if this is a dumb question; I'm very new to MVVM.
Upvotes: 3
Views: 796
Reputation: 5224
There's no "one way rules all" approach, but you'll usually see a 1-1 relationship between views and view-models. In other words, one view-model for a view and this view-model is the data-context for the view. It's common to see a "base" view-model that inherited by the other view-models. This is a very simple explanation, but probably a good starting point for a beginner.
Upvotes: 3