Set BorderBrush color with a trigger

I am having difficulty getting the correct syntax in ControlTemplate. Here is the basic information:

<ControlTemplate TargetType="{x:Type foo:bar">
    <Border Name="Bd">  
        <Border.BorderBrush>
            <SolidColorBrush Color="{DynamicResource DefaultBorderBrushLightBrush}" />
        </Border.BorderBrush>
    </Border>

    <ControlTemplate.Triggers>
        <Trigger Property="IsSelected" Value="true">
            <Setter Property="(Border.BorderBrush).(SolidColorBrush.Color)"
                    TargetName="Bd"
                    Value="{DynamicResource PressedBorderDarkColor}"/>
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate

This gives the msg error

Cannot resolve the Color property of the template. Verify that the owner type is a TargetType type, or use the Class.Property syntax to specify a property.

This seems clear enough - I am not correctly specifying the target property. I tried this in several different ways. In particular, I tried

<Setter Property="BorderBrush" TargetName="Bd">
    <Setter.Value>
        <SolidColorBrush Color="{DynamicResource PressedBorderDarkColor}" />
    </Setter.Value>
</Setter>

... and this creates, and, I believe, gives me what I was looking for.

But why can't I set the color of the brush? How can I specify it?

, " Class.Property"? MSDN XAML , , , .

+3
2

, Style/ControlTemplate TargetType, - Border, , :

<Style x:Key="TestStyle" TargetType="{x:Type Border}>
    <Setter Property="BorderBrush" Value="Green" />

:

<Setter Property="Border.BorderBrush" Value="Green" />

Class.Property , , TargetType:

<Style x:Key="TestStyle">
    <Setter Property="Border.BorderBrush" Value="Red" />

, , :

(Border.BorderBrush).(SolidColorBrush.Color)

Storyboard's.

0

, Border Bd, BorderBrush , SolidColorBrush, BorderBrush. (Border.BorderBrush). (SolidColorBrush.Color) , , TargetProperty StoryBoard, , :

<VisualState x:Name="MouseOver">
                <Storyboard>
                  <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                      (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                                Storyboard.TargetName="Border">
                    <EasingColorKeyFrame KeyTime="0"
                                         Value="{StaticResource ControlMouseOverColor}" />
                  </ColorAnimationUsingKeyFrames>
                </Storyboard>
              </VisualState>
+1

All Articles