Two classes:
public class ObservableCollection<T>
{
public virtual event NotifyCollectionChangedEventHandler CollectionChanged;
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
CollectionChanged.Invoke(this, e);
}
}
public class DerivedObservableCollection<T> : ObservableCollection<T>
{
private bool _SuppressNotification;
public override event NotifyCollectionChangedEventHandler CollectionChanged;
protected virtual void OnCollectionChangedMultiItem(
NotifyCollectionChangedEventArgs e)
{
NotifyCollectionChangedEventHandler handlers = this.CollectionChanged;
if (handlers != null)
{
foreach (NotifyCollectionChangedEventHandler handler in
handlers.GetInvocationList())
{
if (handler.Target is CollectionView)
((CollectionView)handler.Target).Refresh();
else
handler(this, e);
}
}
}
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (!_SuppressNotification)
{
base.OnCollectionChanged(e);//<------is it usefull?------------
if (CollectionChanged != null)
CollectionChanged.Invoke(this, e);
}
}
}
Could one subscribe on ObservableCollection.CollectionChanged in DerivedObservableCollection instance (outside DerivedObservableCollection) and how? Or Is it usefull to call :
base.OnCollectionChanged(e);
?
Actually, I faced this problem with System.Collections.ObjectModel.ObservableCollection and this answer.