ObservableDictionary dla c #
Usiłuję użyć następującego wdrożenia ObservableDictionary:ObservableDictionary (C #).
Kiedy używam następującego kodu podczas wiązania słownika do siatki danych:
ObserveableDictionary<string,string> dd=new ObserveableDictionary<string,string>();
....
dd["aa"]="bb";
....
dd["aa"]="cc";
wdd["aa"]="cc";
Otrzymuję następujący wyjątek
Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index
Ten wyjątek jest wrzucanyCollectionChanged(this, new NotifyCollectionChangedEventArgs(action, newItem, oldItem)
w następujący sposób:
private void OnCollectionChanged(NotifyCollectionChangedAction action, KeyValuePair<TKey, TValue> newItem, KeyValuePair<TKey, TValue> oldItem)
{
OnPropertyChanged();
if (CollectionChanged != null) CollectionChanged(this, new NotifyCollectionChangedEventArgs(action, newItem, oldItem));
}
Theindex
param wydaje się odpowiadaćKeyValuePair<TKey, TValue> oldItem
.
Jak możnaKeyValuePair<TKey, TValue>
być poza zasięgiem i co zrobić, aby to działało?