Dynamic/Generic ViewModelBase?

Posted by Shimmy on Stack Overflow See other posts from Stack Overflow or by Shimmy
Published on 2011-02-07T04:01:26Z Indexed on 2011/02/07 7:25 UTC
Read the original article Hit count: 241

I am learning MVVM now and I understand few things (more than but few are here..):

  1. Does every model potentially exposed (thru a VM) to the View is having a VM?
    For example, if I have a Contact and Address entity and each contact has an Addresses (many) property, does it mean I have to create a ContactViewModel and an AddressViewModel etc.?
  2. Do I have to redeclare all the properties of the Model again in the ViewModel (i.e. FirstName, LastName blah blah)? why not have a ViewModelBase and the ContactViewMode will be a subclass of ViewModelBase accessing the Entity's properties itself? and if this is a bad idea that the View has access to the entity (please explain why), then why not have the ViewModelBase be a DynamicObject (view the Dictionary example @ the link page), so I don't have to redeclare all the properties and validation over and over in the two tiers (M & VM) - because really, the View is anyway accessing the ViewModel's fields via reflection anyway.
  3. I think MVVM was the hardest technology I've ever learned. it doesn't have out-the-box support and there are to many frameworks and methods to achieve it, and in the other hand there is no arranged way to learn it (as MVC for instance), learning MVVM means browsing and surfing around trying to figure out what's better. Bottom line, what I mean by this section is please go and vote to MSFT to add MVVM support in the BCL and generators for VMs and Vs according to the Ms.

Thanks

© Stack Overflow or respective owner

Related posts about mvvm

Related posts about dynamic