Template Binding with Attached Properties Template Binding with Attached Properties wpf wpf

Template Binding with Attached Properties


I think TemplateBinding is evaluated at compile time so you can't dynamically set a TemplateBinding in your Setter, try using Binding instead (see below).

<Setter TargetName="border" Property="BorderBrush"         Value="{Binding Path=(local:ThemeProperties.ButtonBorderColour),                        RelativeSource={RelativeSource TemplatedParent}}"/>

Hope this helps.


Try this:

<Setter TargetName="border" Property="BorderBrush" Value="{TemplateBinding Path=(local:ThemeProperties.ButtonBorderColour)}" />

The difference being that parentheses around the property indicate that it is an attached property.