nomadic posted on Monday, July 20, 2009
Hello
What best practices or patterns have people arrived at for bubbling child modification and validation changes up an object graph to its parents?
So for example, suppose I have a page that is editing a Person object
and its child sub-objects: (this is a contrived and simplified example,
not my actual scenario), and I have the following object hierarchy:
Person
|
|---- ContactDetails
|
|---- Address
I have some buttons on the page that are databound to Person properties like IsValid and IsModified..
How do you bubble up changes to the modification and validation status of the child objects to the root parent?
So basically, if a user opens the page and just changes one of the
properties on the Address child object, giving it an invalid value, I
need the IsValid and IsModified property of the parent Person object to
change and notify its databound observers.
Ideally, I am looking at doing this automatically - so creating some
mechanism to automatically bubble up changes to these properties up the
object graph. Either using reflection, or something like the
RoutedEvent system in WPF.
How do you do it?
Thanks