C
C#17mo ago
mario12136

❔ 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
Angius
Angius17mo ago
If it deserves to be a separate control, it deserves to have a separate view and viewmodel
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server