I have a very simple Checkbox template style. It is working correctly, except the "To" property of the second ColorAnimation is not working properly. It is supposed to bind to the Checkbox's Background, but it doesn't work. Here is the style:
<Style TargetType="CheckBox"><Setter Property="Foreground" Value="White"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="CheckBox"><Grid><VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="CheckStates"><VisualState x:Name="Indeterminate"/><VisualState x:Name="Unchecked"><Storyboard><DoubleAnimation Storyboard.TargetName="TheGrid" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:.2" To="0.2"/><ColorAnimation Storyboard.TargetName="GridBackgroundBrush" Storyboard.TargetProperty="Color" To="Black" Duration="0:0:.2" /></Storyboard></VisualState><VisualState x:Name="Checked"><Storyboard><DoubleAnimation Storyboard.TargetName="TheGrid" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:.2" To="1"/><ColorAnimation Storyboard.TargetName="GridBackgroundBrush" Storyboard.TargetProperty="Color" To="{TemplateBinding Background}" Duration="0:0:.2" /></Storyboard></VisualState></VisualStateGroup></VisualStateManager.VisualStateGroups><Grid Margin="2" x:Name="TheGrid" ><ContentPresenter Grid.Column="1" x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="{TemplateBinding Padding}"/><Grid.Background><SolidColorBrush x:Name="GridBackgroundBrush" ></SolidColorBrush></Grid.Background></Grid></Grid></ControlTemplate></Setter.Value></Setter></Style>
Here is an example of a Checkbox with the style applied (i.e. just a normal Checkbox)
<CheckBox Width="80" Background="Red" Content="Test" Height="80" Click="CheckBox_Click" Margin="2" />
If I change the "To" property from "{TemplateBinding Background}" to "Red", it works fine. What is going wrong?