INotifyPropertyChanged on Business Object

INotifyPropertyChanged on Business Object

Old forum URL: forums.lhotka.net/forums/t/8668.aspx


ixman posted on Tuesday, March 16, 2010

Normal 0 false false false EN-US X-NONE X-NONE

Hi,

This could sound like a stupid question, but I was wondering if the INotifyPropertyChanged should be on the BO if you're using MVVM pattern. Is this just unfortunate in case you're using MVVM? I would see the INPC interface implemented in the view model rather than in the BO.

Any opinions on this?

 

am_fusion replied on Tuesday, March 16, 2010

There are many ways to implement MVVM.  It sounds like you are taking the 'anemic' model approach where the view does not bind directly to the view model... and that's fine.  Most people who are using CSLA and MVVM choose to bind directly to the model because of the rich model CSLA provides.

If you really want to use CSLA, MVVM, and not bind directly to the model you can have your view model hook into the property changed of the CSLA model and re-raise the property changed...  this will work fine if your model properties are exactly the same as your view model properties (in terms of spelling)  if this is not the case then your view model will have to implement some kind of 'translation' (I.E. model has FrstName property and view model has FirstName property).

Also, your ViewModel will just be delegating set\get to the model... so the question you need to ask yourself is why?  Is this just a layer of indirection for the sake of indirection or do you really have a need?

Copyright (c) Marimer LLC