How much do you dislike reflection? The attached is a quick LINQPad mockup of a technique I have used in the past. A "real" implementation would need to be more careful (there is no error handling, no real collection support and circular references will result in stack overflows) but the basics are here.
Essentially this is a new component that is responsible for listening to INotifyPropertyChanged events. When you bind it to a new object it will search through it's properties (via reflection) and try to bind to them recursively as well. The nice thing is that because it also implements INotifyPropertyChanged and exposed a single boolean value you can bind things (like Button enabledness/visibility) to it directly. It's a cheap trick but it works ;) On Mon, May 2, 2011 at 3:19 PM, Greg Keogh <g...@mira.net> wrote: > Folks, in dialog-like screens with OK/Cancel buttons and a bound data > object I like to implement and listen to INotifyPropertyChanged on the data > object so I know the screen is “dirty” and I enable the OK button. > > > > When the data bound object is composed from a nest of other objects, it > becomes impractical to pass changed events up through the levels of objects > to the top. It can be done by manually sending the event up through > child-parent objects, but the code to create this sort of “event bubbling” > is verbose and tedious. > > > > Is there some trick that I’m not aware of for creating mock property > changed “event bubbling” in my own nested objects? > > > > Greg > > >
DirtyTracking.linq
Description: Binary data