I want to have Dictionary that would be 'Observable' in order to throw events when its item changing (Remove or Add).
In other class I created such dictionary and set Binding to ListBox.ItemsSourseProperty
.
The Binding work well. I can see the items.
But something is wrong: the event PropertyChanged
always null.
Can anyone help?
Thanks in advance!
class ObservableDictionary<TKey, TValue> :
Dictionary<TKey, TValue>,
INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public new void Remove(TKey obj)
{
base.Remove(obj);
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Remove"));
}
}
}