What's wrong with the following generic Style
defined in my Button's ControlTemplate.Resources
?
<ControlTemplate x:Key="ZeroButtonTemplate" TargetType="Button">
<ControlTemplate.Resources>
<Style TargetType="{x:Type Rectangle}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsRunning}" Value="True">
<Setter Property="Fill" Value="LightGray" />
</DataTrigger>
<EventTrigger RoutedEvent="Button.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation From="Black" To="Red" Duration="00:00:00.5" Storyboard.TargetProperty="Fill" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</ControlTemplate.Resources>
<ContentPresenter Content="{TemplateBinding Content}" />
</ControlTemplate>
Neither the DataTrigger
nor the EventTrigger
appear to be working.
For sake of completion, my Button is defined like this:
<Button Template="{StaticResource ZeroButtonTemplate}">
<Button.Content>
<Rectangle Width="15" Height="15" Fill="Black" />
</Button.Content>
</Button>
Change target property of animation to
Fill.Color