❔ When to separate controls into their own Views and Viewmodels?
While I'd like to think I understand MVVM, this is a question that I think is not really covered.
It is quite easy to have a main view model, if your app has window, that is full of commands and properties, bound to menuitems and buttons.
How do I know that a control perhaps deserves its own view and viewmodel. Technically, what I have for my application, I can see it go either way: (1) have everything in the main view model or (2) separate certain controls into their own viewmodels.
How do I make that decision? Even if this question is a matter of preference, what is your preference and though process. Would it ever make sense to have the File menu have its own view model. How about a tight knit group of controls, or popups that only display data (maybe a lot of data)?
If I do end up with multiple views that need view models in my main view, how best to provide these view models as data contexts if their contructors have params (DI)?
2 Replies