Reflect property changes in index for classes that support INotifyChanging and INotifyChanged


I greatly like this library, but to be able to use it in one of my projects, I need support for propertychanges to items in the IndexableCollection. Ideal would be to automatically update indexed properties of classes that implement INotifyPropertyChanged and INotifyPropertyChanging.
I'll try to submit a patch which implements just that.


wrote Apr 25, 2009 at 9:35 PM

Resolved with changeset 33509.

staxmanade wrote Apr 25, 2009 at 9:38 PM

Thanks for the patch...

I've created a branch, checked in your changes (to the branch), and added one test and fix for the case when a raised property changed event throws a bad property name.

I would like to spend some more time thinking about this change and other side affects it may cause. (performance, etc) before it is merged in, however this is one of the big ticket items Aaron and I both feel the library should support.

Thanks again,
Jason (Staxmanade)

wrote Apr 25, 2009 at 9:52 PM

wrote Apr 25, 2009 at 9:52 PM

Lashas wrote Aug 6, 2009 at 11:12 PM

I have optimizied a littile bit (adding item to list is ~30-40% faster) by changing how handlers are attached to item. Instead of
(item as INotifyPropertyChanged).PropertyChanged += IndexableCollection_PropertyChanged;
I've changed to
(item as INotifyPropertyChanged).PropertyChanged += _propertyChangedHandler;
while _propertyChangedHandler is private field in IndexableCollection, and is initialized in constructor by this line "
_propertyChangedHandler = new PropertyChangedEventHandler(IndexableCollection_PropertyChanged);"

Finally this left me with same performance as object would be without INotifyPropertyChanged interface.

wrote Aug 7, 2009 at 5:45 AM

Test comment from V.S. /tfs since I can't hit the codeplex website.

wrote Aug 7, 2009 at 5:52 AM

Great suggestion. It's funny how I didn't notice that. By using the C# syntactic sugar (where we don't specify "prop += new EventHandler(Handler)" and instead use "prop += Handler") I didn't even think about it haveing to create a new object for each pass...
Thanks for the contribution.

wrote Feb 14, 2011 at 4:14 PM

wrote Feb 14, 2013 at 2:52 AM