Dimitri Dimitri - 1 year ago 140
C# Question

Code-Heavy ViewModels in MVVM

I'm writing an application in WPF and found myself loving whole MVVM paradigm. My only concern at the moment is that my ViewModels are becoming heavy. They contain

, logic to enable and disable buttons, instances of other ViewModels, async method with
timers etc. Is this something that is normal in this kind of development environment? Or is there some logical way of organizing ViewModels without becoming too "crowded"?

Answer Source

Keep in mind that the ViewModel is just an adapter between your model, where logic and data live, and the view which is shown to the user.

The idea is you can easily swap views or change them, without the logic suffering from that.

Having said that, depending on the complexity of your application, they might grow quite big, but if it's mainly stuff that ends up enabling/disabling stuff on your view, and isn't doing logic / processing stuff, I'd say this is where it's supposed to live.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download