コード例 #1
0
        protected override void RemoveItem(int index)
        {
            if (IsNotificationsSuspended)
            {
                _IsDirty = true;
            }
            else
            {
                var collectionChangingEventArgs = new CollectionChangingEventArgs <T>(Items[index], index, CollectionChangeAction.Remove);
                CollectionChanging(this, collectionChangingEventArgs);
                if (collectionChangingEventArgs.Cancel)
                {
                    return;
                }
            }

            base.RemoveItem(index);
        }
コード例 #2
0
        protected override void ClearItems()
        {
            if (IsNotificationsSuspended)
            {
                _IsDirty = true;
            }
            else
            {
                var collectionChangingEventArgs = new CollectionChangingEventArgs <T>(default(T), 0, CollectionChangeAction.Refresh);
                CollectionChanging(this, collectionChangingEventArgs);
                if (collectionChangingEventArgs.Cancel)
                {
                    return;
                }
            }

            base.ClearItems();
        }
コード例 #3
0
        protected override void InsertItem(int index, T item)
        {
            if (IsNotificationsSuspended)
            {
                _IsDirty = true;
                base.InsertItem(index, item);
            }
            else
            {
                var collectionChangingEventArgs = new CollectionChangingEventArgs <T>(item, index, CollectionChangeAction.Add);
                CollectionChanging(this, collectionChangingEventArgs);

                if (collectionChangingEventArgs.Cancel)
                {
                    return;
                }

                base.InsertItem(index, collectionChangingEventArgs.Item);
            }
        }