ObservableDictionary para c #
Estoy tratando de usar la siguiente implementación del ObservableDictionary:ObservableDictionary (C #).
Cuando estoy usando el siguiente código mientras vinculo el diccionario a un DataGrid:
ObserveableDictionary<string,string> dd=new ObserveableDictionary<string,string>();
....
dd["aa"]="bb";
....
dd["aa"]="cc";
add["aa"]="cc";
Estoy recibiendo la siguiente excepción
Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index
Esta excepción es lanzada enCollectionChanged(this, new NotifyCollectionChangedEventArgs(action, newItem, oldItem)
en el siguiente método:
private void OnCollectionChanged(NotifyCollectionChangedAction action, KeyValuePair<TKey, TValue> newItem, KeyValuePair<TKey, TValue> oldItem)
{
OnPropertyChanged();
if (CollectionChanged != null) CollectionChanged(this, new NotifyCollectionChangedEventArgs(action, newItem, oldItem));
}
losindex
param parece corresponder aKeyValuePair<TKey, TValue> oldItem
.
Como puedeKeyValuePair<TKey, TValue>
estar fuera de rango, y ¿qué debo hacer para que esto funcione?