Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a specific solution for extending the ObservableCollection class to one that monitors changes in the properties of the objects it contains <a href="https://stackoverflow.com/questions/269073/observablecollection-that-also-monitors-changes-on-the-elements-in-collection">here</a>.</p> <p>Here's that code with a few modifications by me:</p> <pre><code>namespace Solution { public class ObservableCollectionEx&lt;T&gt; : ObservableCollection&lt;T&gt; where T : INotifyPropertyChanged { protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { if (e != null) // There's been an addition or removal of items from the Collection { Unsubscribe(e.OldItems); Subscribe(e.NewItems); base.OnCollectionChanged(e); } else { // Just a property has changed, so reset the Collection. base.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } } protected override void ClearItems() { foreach (T element in this) element.PropertyChanged -= ContainedElementChanged; base.ClearItems(); } private void Subscribe(IList iList) { if (iList != null) { foreach (T element in iList) element.PropertyChanged += ContainedElementChanged; } } private void Unsubscribe(IList iList) { if (iList != null) { foreach (T element in iList) element.PropertyChanged -= ContainedElementChanged; } } private void ContainedElementChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged(e); // Tell the Collection that the property has changed this.OnCollectionChanged(null); } } } </code></pre>
    singulars
    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. VO
      singulars
      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