标签:des style blog http ar io color os sp
What is the difference between these 2 bindings:
<ControlTemplate TargetType="{x:Type Button}"> <Border BorderBrush="{TemplateBinding Property=Background}"> <ContentPresenter /> </Border> </ControlTemplate>
and
<ControlTemplate TargetType="{x:Type Button}"> <Border BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"> <ContentPresenter /> </Border> </ControlTemplate>
TemplateBinding - More limiting than using regular Binding
Regular Binding - Does not have above limitations of TemplateBinding
One more thing - TemplateBindings don‘t allow value converting. They don‘t allow you to pass a Converter and don‘t automatically convert int to string for example (which is normal for a Binding).
TempleteBinding is a shorthand for Binding with TemplatedParent but it does not expose all the capabilities of the Binding class, for example you can‘t control Binding.Mode from TempleteBinding.
[WPF系列-高级TemplateBinding vs RelativeSource TemplatedParent]
标签:des style blog http ar io color os sp
原文地址:http://www.cnblogs.com/HQFZ/p/4169874.html