You can use an ICollectionView
that has some extended functionality for filtering as well. If you want a premade class, check out one available at Code Project.
In particular, I noticed that the UI subscribes to the VectorChanged
event, so you should be good with only implementing IObservableCollection
noted earlier in the comments.
The VectorChanged
event takes an interface of type IVectorChangedEventArgs
, and I found no concrete classes when looking around. It's not difficult to create one though. Here's one that can be created similar to how you create an instance of NotifyPropertyChangedEventArgs
. It's private since it's only used in the collection class.
private sealed class VectorChangedEventArgs : IVectorChangedEventArgs
{
public VectorChangedEventArgs(NotifyCollectionChangedAction action, object item, int index)
{
switch (action)
{
case NotifyCollectionChangedAction.Add:
CollectionChange = CollectionChange.ItemInserted;
break;
case NotifyCollectionChangedAction.Remove:
CollectionChange = CollectionChange.ItemRemoved;
break;
case NotifyCollectionChangedAction.Move:
case NotifyCollectionChangedAction.Replace:
CollectionChange = CollectionChange.ItemChanged;
break;
case NotifyCollectionChangedAction.Reset:
CollectionChange = CollectionChange.Reset;
break;
default:
throw new ArgumentOutOfRangeException("action");
}
Index = (uint)index;
Item = item;
}
/// <summary>
/// Gets the affected item.
/// </summary>
public object Item { get; private set; }
/// <summary>
/// Gets the type of change that occurred in the vector.
/// </summary>
public CollectionChange CollectionChange { get; private set; }
/// <summary>
/// Gets the position where the change occurred in the vector.
/// </summary>
public uint Index { get; private set; }
}