ObservableDictionary para c #
Estou tentando usar a seguinte implementação do ObservableDictionary:ObservableDictionary (C #).
Quando estou usando o código a seguir enquanto vinculo o dicionário a um DataGrid:
ObserveableDictionary<string,string> dd=new ObserveableDictionary<string,string>();
....
dd["aa"]="bb";
....
dd["aa"]="cc";
add["aa"]="cc";
Estou recebendo a seguinte exceção
Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index
Esta exceção é lançada emCollectionChanged(this, new NotifyCollectionChangedEventArgs(action, newItem, oldItem)
no seguinte 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));
}
oindex
param parece corresponder aKeyValuePair<TKey, TValue> oldItem
.
Como podeKeyValuePair<TKey, TValue>
estar fora de alcance e o que devo fazer para que isso funcione?