2014년 3월 10일 월요일

[C#, WPF] Implementation of ObservableDictionary class

Why it need?

ObservableCollection<T> allow to automatic renew to UI. (Only WPF)

So you don't need to concern about changing of Collection.

But Sometime need binding UI with Dictionary and automatical renewal.

Because ObservableDictionary is not exist in standard library, need to implement.

How implement?

ObservableCollection<T> class use INotifyCollectionChanged interface.

So if you want to implement own ObservableCollection class,

need to implement INotifyCollectionChanged interface.


INotifyCollectionChanged interface expose only CollectionChanged

When collection changed, must call CollectionChanged event.

Example(C#)

Example code is created in Visual Studio 2013.


If you use lower version, just copy "ObservableDictionary.cs"