示例#1
0
 /// <inheritdoc />
 public void Clear()
 {
     ViewModels.Clear();
     EncapsulatedList.Clear();
     OnAllPropertiesChanged();
     CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
     ClearItemCsommand.OnCanExecuteChanged();
     RemoveItemCommand.OnCanExecuteChanged();
 }
示例#2
0
 public void Insert(int index, TViewModel item)
 {
     if (ViewModels.Contains(item) || EncapsulatedList.Contains(item?.Model))
     {
         throw new NotSupportedException("The item was already added to the collection");
     }
     ViewModels.Insert(index, item);
     EncapsulatedList.Insert(index, item?.Model);
     CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
     ClearItemCsommand.OnCanExecuteChanged();
     RemoveItemCommand.OnCanExecuteChanged();
     OnAllPropertiesChanged();
 }
示例#3
0
        /// <inheritdoc />
        public bool Remove(TViewModel item)
        {
            int  index       = ViewModels.IndexOf(item);
            bool returnValue = ViewModels.Remove(item);

            EncapsulatedList.Remove(item?.Model);
            CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
            ClearItemCsommand.OnCanExecuteChanged();
            RemoveItemCommand.OnCanExecuteChanged();
            OnAllPropertiesChanged();

            return(returnValue);
        }
示例#4
0
 /// <inheritdoc />
 public void Add(TViewModel item)
 {
     if (ViewModels.Contains(item) || EncapsulatedList.Any(i => ReferenceEquals(i, item?.Model)))
     {
         throw new NotSupportedException("The item was already added to the collection");
     }
     ViewModels.Add(item);
     EncapsulatedList.Add(item?.Model);
     CollectionChanged?.Invoke(ViewModels,
                               new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item));
     OnAllPropertiesChanged();
     ClearItemCsommand.OnCanExecuteChanged();
     RemoveItemCommand.OnCanExecuteChanged();
 }