コード例 #1
0
        /// <inheritdoc/>
        protected override void RemoveItem(int index)
        {
            var collectionChanged = itemRemoved;

            if (collectionChanged != null)
            {
                var e = new FastTrackingCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, this[index], null, index, true);
                collectionChanged(this, ref e);
            }
            base.RemoveItem(index);
        }
コード例 #2
0
        /// <inheritdoc/>
        protected override void InsertItem(int index, T item)
        {
            base.InsertItem(index, item);
            var collectionChanged = itemAdded;

            if (collectionChanged == null)
            {
                return;
            }
            var e = new FastTrackingCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, null, index, true);

            collectionChanged(this, ref e);
        }
コード例 #3
0
        protected void ClearItemsEvents()
        {
            var collectionChanged = itemRemoved;

            if (collectionChanged == null)
            {
                return;
            }
            for (var i = Count - 1; i >= 0; --i)
            {
                var e = new FastTrackingCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, this[i], null, i, true);
                collectionChanged(this, ref e);
            }
        }
コード例 #4
0
        /// <inheritdoc/>
        protected override void SetItem(int index, T item)
        {
            // Note: Changing CollectionChanged is not thread-safe
            var collectionChangedRemoved = itemRemoved;

            var oldItem = (collectionChangedRemoved != null) ? (object)this[index] : null;

            if (collectionChangedRemoved != null)
            {
                var e = new FastTrackingCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, oldItem, null, index);
                collectionChangedRemoved(this, ref e);
            }

            base.SetItem(index, item);

            var collectionChangedAdded = itemAdded;

            if (collectionChangedAdded != null)
            {
                var e = new FastTrackingCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, oldItem, index);
                collectionChangedAdded(this, ref e);
            }
        }