나는 이런 식으로 뭔가를 할 노력하고있어 ...내 WPF 스타일 설정 기가 TemplateBinding을 사용할 수 있습니까?
<Style
x:Key="MyBorderStyle"
TargetType="Border">
<Setter
Property="BorderBrush"
Value="{StaticResource MyBorderBrush}" />
<Setter
Property="Background"
Value="{StaticResource MyBackgroundBrush}" />
<Setter
Property="Padding"
Value="{TemplateBinding Padding}" />
</Style>
...하지만 오류 얻을 : 나는 "자격 유형 이름"을 제공하려면 어떻게 'Padding' member is not valid because it does not have a qualifying type name.
를?
참고 :이 작업을 수행하려는 이유는 동일한 테두리를 일련의 유사한 ControlTemplates에 포함시키고 싶기 때문입니다.
감사합니다.
편집 : 그럼 난이 시도
...
<Setter
Property="Padding"
Value="{TemplateBinding GridViewColumnHeader.Padding}" />
... 그리고 실제로 컴파일,하지만 내가 응용 프로그램을 실행했을 때, 나는 XamlParseException
가지고 :
Cannot convert the value in attribute 'Value' to object of type ''.
Padding
은 GridViewColumnHeader
(이 스타일을 사용하려는 ControlTemplate)은 작동하지만 주사위는 사용하지 않습니다.
편집 2 :
음, TemplateBinding
의 문서에 따르면, 말한다 : 내가 할 노력하고있어 것은 그냥 일반 불가능처럼
Links the value of a property in a control template to be the value of some other exposed property on the templated control.
그래서 소리가 난다. 난 정말 내 컨트롤 템플릿에서 특정 컨트롤에 대한 재사용 가능한 스타일을 만들 수 싶습니다,하지만 템플릿 바인딩은 이러한 스타일에 포함되지 않을 것 같아요.
좋은 생각, 셰인. 감사. – devuxer