私はObservableCollection<Person>
を使用します。 SortedSetが本当に必要な場合は、INotifyCollectionChangedインターフェイスとINotifyPropertyChangedインターフェイスを実装することもできます。あなたが前に進むことができ
一つの方法はそうのように、巻き付けたSortedSetあなたのコレクションクラスを作成することができます
public class ObservableSortedSet<T> : ICollection<T>,
INotifyCollectionChanged,
INotifyPropertyChanged
{
readonly SortedSet<T> _innerCollection = new SortedSet<T>();
public IEnumerator<T> GetEnumerator()
{
return _innerCollection.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Add(T item)
{
_innerCollection.Add(item);
// TODO, notify collection change
}
public void Clear()
{
_innerCollection.Clear();
// TODO, notify collection change
}
public bool Contains(T item)
{
return _innerCollection.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
_innerCollection.CopyTo(array, arrayIndex);
}
public bool Remove(T item)
{
_innerCollection.Remove(item);
// TODO, notify collection change
}
public int Count
{
get { return _innerCollection.Count; }
}
public bool IsReadOnly
{
get { return ((ICollection<T>)_innerCollection).IsReadOnly; }
}
// TODO: possibly add some specific methods, if needed
public event NotifyCollectionChangedEventHandler CollectionChanged;
public event PropertyChangedEventHandler PropertyChanged;
}
感謝;-)良いアイデア;-) – Svisstack