[WPF] ResourceTemplate And Button - ControlTemplate !!
gsi
2007. 12. 13. 17:36
ControlTemplate 태그 내에는 TargetType 속성을 포함하는 것이 가능하다. <ControlTemplate x:Key="btnCustom" TargetType="{x:Type Button}"> 이 경우 TemplateBinding 표현에서 의존 프로퍼티의 클래스 이름을 앞에 붙일 필요는 없다. 바인딩에는 이 프로퍼티를 참조하라는 정보가 들어 있기 때문.
여러개의 컨트롤이 템플릿을 공유할때 리소스로 정의해야 한다.
btnCustom이라는 x:Key를 가진 ControlTemplate을 정의한 스탠드 얼론 xaml파일이 있다.
ControlTemplate 상에 TargetType 속성을 설정한 이유는 의존 프로퍼티나 이벤트 앞에 반복해서 클래스 이름을 붙이지 않기 위함이다.