2014년 4월 10일 목요일

[C#, WPF] ObservableStack

닷넷의 컬렉션 중에서

배열이나 리스트는 XML 직렬화나 데이터 바인딩에 대해서 걱정할 것이 없는데

사전이나 스택같은 구조는 사용자가 직접 구현해야(...)하더군요


그런데 이왕이면 원래 코드에 약간의 코드만 추가하면 되는 것이라

어떻게 하면 쉽게 될까 했는데

ILSpy라는 DLL의 내용을 볼 수 있는 프로그램이 있더군요

덕분에 원래 스택코드를 복붙해서 할 수 있었습니다 ㅎㅎ

ObservableStack(데이터 바인딩을 위한 스택) 테스트 프로젝트
프로젝트 테스트 방법은 실행 후

엔터 -> 랜덤값 Push
딜리트 -> 최상위값 삭제
ESC -> 스택 초기화

입니다

그리고 위의 ObservableStack에 추가적으로 XML직렬화 기능을 넣어서
새로운 스택을 만들었습니다
https://www.dropbox.com/s/t6dwfdcpp8q5i2b/CustomizeStack.cs

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"