我想,当鼠标进入按钮时,按钮字体的前景变为另一种颜色
我为我的按钮设置了这种风格但不起作用动画
<Style x:Key="StartButton" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="{Binding solid1}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}" x:Name="Body">
<Grid Name="Figure">
<Grid.Resources>
<SolidColorBrush x:Key="solid1" x:Name="solid2" Color="Black"/>
</Grid.Resources>
.
.
.
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="Click">
<BeginStoryboard>
<Storyboard Storyboard.TargetName="solid2"
Storyboard.TargetProperty="Color">
<ColorAnimation From="Black" To="Red"
Duration="0:0:1">
</ColorAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
感谢。
答案 0 :(得分:0)
而不是
Storyboard.TargetName="solid2"
试
Storyboard.Target="{StaticResource solid1}"