Is there a way to pause the NotifyCollectionChanged
event of an ObservableCollection
? I thought something like the following:
public class PausibleObservableCollection<Message> : ObservableCollection<Message>
{
public bool IsBindingPaused { get; set; }
protected override void OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (!IsBindingPaused)
base.OnCollectionChanged(e);
}
}
This pauses the notification indeed, but obviously the then left out (but still added) items are within the NotifyCollectionChangedEventArgs
and are therefore not passed to the bound DataGrid when I enable the notification again.
Will I have to come up with a custom implementation of a collection in order to control this aspect?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…