Hello,
I'm trying to create a Observable Dictionary Class for WPF DataBinding in C#. I found a nice example from Andy here: http://stackoverflow.com/questions/800130/two-way-data-binding-with-a-dictionary-in-wpf/800217
According to that, I tried to change the code to following:
class ObservableDictionary : ViewModelBase
{
public ObservableDictionary(Dictionary<TKey, TValue> dictionary)
{
_data = dictionary;
}
private Dictionary<TKey, TValue> _data;
public Dictionary<TKey, TValue> Data
{
get { return this._data; }
}
private KeyValuePair<TKey, TValue>? _selectedKey = null;
public KeyValuePair<TKey, TValue>? SelectedKey
{
get { return _selectedKey; }
set
{
_selectedKey = value;
RaisePropertyChanged("SelectedKey");
RaisePropertyChanged("SelectedValue");
}
}
public TValue SelectedValue
{
get
{
return _data[SelectedKey.Value.Key];
}
set
{
_data[SelectedKey.Value.Key] = value;
RaisePropertyChanged("SelectedValue");
}
}
}
}
Unfortunately I still don't know how to pass "general" Dictionary Objects.. any ideas?
Thank you!
Cheers