I'm building a custom control in Silverlight and I want one of the fields to animate to the value of a DependencyProperty when that property is changed. More specifically, I have particular item in my Control Template that I want to animate to the color of the Background whenever the background changes color. So, what I have is:
<ControlTemplate TargetType="local:MyType">
<Grid x:Name="PART_RootElement">
<Grid.Resources>
<Storyboard x:Name="PART_FillAnimation">
<ColorAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="PART_MainPath"
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
<EasingColorKeyFrame
x:Name="PATH_FillKeyframe"
KeyTime="00:00:01"
Value="{TemplateBinding Background}"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<!-- the rest of the template -->
I'm triggering the animation in the custom control code, but when the animation starts, it doesn't look like the Value is updating. I was just wondering if I'm missing something or if it is at all possible to apply TemplateBinding to resources in my ControlTemplate.
(I'm currently using a work-around of manually assigning the Background to the EasingColorKeyFrame Value, but the TemplateBinding solution would be so much cleaner.)