在style中定义ColorAnimation
<Style x:Key="MyTextBlockStyle" TargetType="{x:Type TextBlock}">
<Setter Property="TextWrapping" Value="NoWrap" />
<Setter Property="TextTrimming" Value="None" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Foreground" Value="Orange" />
<Setter Property="FontFamily" Value="SongT" />
<Style.Triggers>
<EventTrigger RoutedEvent="TextBlock.MouseEnter">
<BeginStoryboard>
<Storyboard Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
<ColorAnimation From="Orange" To="DodgerBlue" Duration="0:0:0.1"></ColorAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="TextBlock.MouseLeave">
<BeginStoryboard>
<Storyboard Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
<ColorAnimation From="DodgerBlue" To="Orange" Duration="0:0:0.1"></ColorAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
添加到App资源或者页面资源中,并且引用