ICollectionView
フィルタリング用の拡張機能を備えた を使用することもできます。既製のクラスが必要な場合は、 Code Project で入手できるものをチェックしてください。
特に、UI がイベントにサブスクライブしていることに気付きました。そのため、コメントで前述したVectorChanged
実装のみを行うのが適切なはずです。IObservableCollection
VectorChanged
イベントは type のインターフェースを取り、周りIVectorChangedEventArgs
を見回しても具象クラスは見つかりませんでした。ただし、作成するのは難しくありません。のインスタンスを作成する方法と同様に作成できるものを次に示しますNotifyPropertyChangedEventArgs
。コレクションクラスでのみ使用されるため、プライベートです。
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; }
}