[System.ComponentModel] BindingList.ListChanged now attempts to provide a PropertyDes...
authorAlexis Christoforides <alexis@thenull.net>
Thu, 19 Jun 2014 02:11:43 +0000 (22:11 -0400)
committerAlexis Christoforides <alexis@thenull.net>
Thu, 19 Jun 2014 02:11:43 +0000 (22:11 -0400)
BindingList subscribes to PropertyChanged events of eligible contained objects. Iff the PropertyName provided is valid,
the list event's ListChangedEventArgs will also contain a PropertyDescriptor.

This is to match MS behavior.

mcs/class/System/System.ComponentModel/BindingList.cs

index b4c0ce8b69b1cb2ba325bf0bd81adaa229b173eb..181b91dbbc9bced4f86b7669fd27b2b40d5ab51b 100644 (file)
@@ -248,7 +248,14 @@ namespace System.ComponentModel {
 
                void Item_PropertyChanged (object item, PropertyChangedEventArgs args)
                {
-                       OnListChanged (new ListChangedEventArgs (ListChangedType.ItemChanged, base.IndexOf ((T) item)) );
+                       var property_info = item.GetType ().GetProperty (args.PropertyName);
+
+                       if (property_info != null) {
+                               OnListChanged (new ListChangedEventArgs (ListChangedType.ItemChanged, base.IndexOf ((T) item),
+                                                       new ReflectionPropertyDescriptor (property_info)) );
+                       } else {
+                               OnListChanged (new ListChangedEventArgs (ListChangedType.ItemChanged, base.IndexOf ((T) item)) );
+                       }
                }
 
                protected virtual void OnAddingNew (AddingNewEventArgs e)