A very quick and easy way is to subclass ObservableCollection and suspend notifications when AddRange is called. You could try to refer to it according to your needs.
public class MyObservableCollection<T> : ObservableCollection<T>
{
private bool myNotification = false;
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (!myNotification)
base.OnCollectionChanged(e);
}
public void AddRange(IEnumerable<T> list)
{
if (list == null)
throw new ArgumentNullException("list");
myNotification = true;
foreach (T item in list)
{
Add(item);
}
myNotification = false;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
----------------------------------------------------------------------------
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.