Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found in constructor some interesting things:</p> <pre><code>public BindingList() { // ... this.Initialize(); } private void Initialize() { this.allowNew = this.ItemTypeHasDefaultConstructor; if (typeof(INotifyPropertyChanged).IsAssignableFrom(typeof(T))) // yes! all you're right { this.raiseItemChangedEvents = true; foreach (T local in base.Items) { this.HookPropertyChanged(local); } } } </code></pre> <p>Quick fix 4 this behavior:</p> <pre><code>public class BindingListFixed&lt;T&gt; : BindingList&lt;T&gt; { [NonSerialized] private readonly bool _fix; public BindingListFixed() { _fix = !typeof (INotifyPropertyChanged).IsAssignableFrom(typeof (T)); } protected override void InsertItem(int index, T item) { base.InsertItem(index, item); if (RaiseListChangedEvents &amp;&amp; _fix) { var c = item as INotifyPropertyChanged; if (null!=c) c.PropertyChanged += FixPropertyChanged; } } protected override void RemoveItem(int index) { var item = base[index] as INotifyPropertyChanged; base.RemoveItem(index); if (RaiseListChangedEvents &amp;&amp; _fix &amp;&amp; null!=item) { item.PropertyChanged -= FixPropertyChanged; } } void FixPropertyChanged(object sender, PropertyChangedEventArgs e) { if (!RaiseListChangedEvents) return; if (_itemTypeProperties == null) { _itemTypeProperties = TypeDescriptor.GetProperties(typeof(T)); } var propDesc = _itemTypeProperties.Find(e.PropertyName, true); OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, IndexOf((T)sender), propDesc)); } [NonSerialized] private PropertyDescriptorCollection _itemTypeProperties; } </code></pre> <p>Thanks for replies!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload