ObservableCollection에 대해 질문 드립니다

이런 식으로 ObservableCollection를 재정의 하시면 됩니다.
AddRange와 비슷한 논리로 삭제도 구현하시면 됩니다.

using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;

CustomObservableCollection<int> list = new();
list.CollectionChanged += (s, e) =>
{
    Console.WriteLine(e.NewItems?.Count ?? 0);
};

list.Add(1);
list.Add(2);
list.Add(3);

list.AddRange(new[] { 4, 5, 6 });

public class CustomObservableCollection<T> : ObservableCollection<T>
{
    public void AddRange(IList<T> list)
    {
        foreach (var item in list)
            Items.Add(item);

        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, list as IList));
    }
}

| 출력결과

1
1
1
3
7개의 좋아요