Implement INotifyPropertyChanged
Posted
by yossharel
on Stack Overflow
See other posts from Stack Overflow
or by yossharel
Published on 2010-05-18T14:55:42Z
Indexed on
2010/05/20
7:00 UTC
Read the original article
Hit count: 309
c#
Hi all,
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 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"));
}
}
}
© Stack Overflow or respective owner