예제 #1
0
        protected override void InsertItem(int index, T item)
        {
            base.InsertItem(index, item);

            if (item is INotifyPropertyChanged notify)
            {
                notify.PropertyChanged += Item_PropertyChanged;
            }

            Added?.Invoke(this, new SingleChangeEventArgs <T>(index, item, SingleChangeType.Added));
            AddedAny?.Invoke(this, new SingleChangeEventArgs <T>(index, item, SingleChangeType.Added));
        }
예제 #2
0
        protected override void SetItem(int index, T newItem)
        {
            T oldItem = this[index];

            if (oldItem is INotifyPropertyChanged oldNotify)
            {
                oldNotify.PropertyChanged -= Item_PropertyChanged;
            }

            base.SetItem(index, newItem);
            Set?.Invoke(this, new SetItemEventArgs <T>(index, oldItem, newItem));

            if (newItem is INotifyPropertyChanged newNotify)
            {
                newNotify.PropertyChanged += Item_PropertyChanged;
            }

            RemovedAny?.Invoke(this, new SingleChangeEventArgs <T>(index, oldItem, SingleChangeType.Removed));
            AddedAny?.Invoke(this, new SingleChangeEventArgs <T>(index, newItem, SingleChangeType.Added));
        }