티스토리 뷰
C#
Making Custom Control with DefaultStyleKeyProperty.OverrideMetadata in the static constructor.
갱생쌩유 2015. 9. 23. 14:24Wpf에서 Custom Control 을 만들 때 유심히 봐야 할 내용이
바로 static 생성자 안에서 정의하는 DefaultStyleKeyProperty.OverrideMetadata 일 것 같다.
내가 확실하게 번역한 내용인지는 모르겠으나 대충 의역한 내용에 따르면
DefaultStyleKeyProperty.OverrideMetadata 을 정의하지 않으면
Custom Control 에서 상속받는 부모 클래스의 기본 Style을 따르게 된다고 한다.
즉, 나만의 Custom Control 에서 새로운 Style을 지정하기 위해선
static 생성자에서 반드시 DefaultStyleKeyProperty.OverrideMetadata 를 정의해 줘야 한다.
그리고 Style을 지정해주는 .xaml 파일은 반드시 Theme 폴더 밑에 정의해줘야 한다.
이어서 Custom Control 과 User Control 의 차이점을 명시한 사이트 출처를 밝힌다.
http://www.codeproject.com/Articles/179442/So-what-s-the-difference-between-a-Custom-Control
'C#' 카테고리의 다른 글
ThreadPool with WaitHandle (0) | 2015.09.17 |
---|---|
Difference between AutoResetEvent and ManualResetEvent (0) | 2015.09.17 |
Win32 API GetMonitorInfo() (0) | 2014.04.09 |
WPF OpenFileDialog 창 폴더 선택하기. (0) | 2013.09.16 |
ListView & TreeView 이만한 더블버퍼링은 없다. (0) | 2013.05.14 |