<Border Name="ItemBorder" Margin="5 5 0 5" BorderBrush="Black" BorderThickness="1" Height="75" Width="75">
<Border.Background>
<SolidColorBrush x:Name="ItemBorderBrush" Color="LightBlue"/>
</Border.Background>
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="someEvent">
<BeginStoryboard>
<Storyboard TargetName="ItemBorderBrush" TargetProperty="Color" Duration="0:0:1" >
<!--Storyboard TargetName="ItemBorder" TargetProperty="Background.Color" Duration="0:0:1"> -->
<ColorAnimation To="White"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
I'll try to explain my question clearly. The Storyboard Target name, when it is "ItemBorder" (the commented out line) works intermittently. Sometimes I get an error that the name "ItemBorder" cannot be found in the scope.
I decided to follow a style from an MSDN example of this, and change the color property directly on the brush, instead of having the target of the storyboard be the border, and changing the color of the border's brush by property (the commented out line). This seems to work.
However, Name="ItemBorderBrush"
does not compile because Name
is not a property of SolidColorBrush
so I use x:Name="ItemBorderBrush"
Both Name
and x:Name
are accepted for the Border. Why is this?
What does the x:
mean (how is x:Name
different from Name
), and why would having the Name
property of border only work with the storyboard sometimes?