TemplateBinding vs TemplatedParent
TemplateBinding, TemplatedParent
두 기법 모두 Template이 적용된 Element의 속성과 바인딩 하기 위해 존재한다.
TemplateBinding
EX) TemplateBinding
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderBrush="{TemplateBinding Property=Background}">
<ContentPresenter />
</Border>
</ControlTemplate>
- TemplateBindings는 ControlTemplate에 지정된 타입에 대해 컴파일 타임에 처리된다.
이를 통해 Template 컴파일이 빠르다. - ControlTemplate 안에서만 사용 가능하다.
- Value Converting 사용할 수 없다.
TemplatedParent
EX) TemplatedParent
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}">
<ContentPresenter />
</Border>
</ControlTemplate>
- 일반적인 바인딩 방식이다
- 런타임에 처리된다. 그래서 컴파일이 더 느리다.
Author And Source
이 문제에 관하여(TemplateBinding vs TemplatedParent), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@mohadang/TemplateBinding-vs-TemplatedParent저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)