【发布时间】:2026-02-17 01:40:01
【问题描述】:
我只是想让一些文本在此 TextBlock 的源更新时瞬间闪烁红色。 TextBlock 绑定的文本可以正常工作,但由于某种原因动画不会触发。我有点不知所措。
有什么想法吗?
<Border BorderBrush="{StaticResource Button.BackgroundBrush}"
Background="{StaticResource Screener.Background}"
BorderThickness="0,1,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<TextBlock Text="{Binding AlertBoxMessage, Mode=OneWay, NotifyOnSourceUpdated=True}"
Name="AlertBox"
MinHeight="55"
FontWeight="Normal"
FontSize="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Black">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<EventTrigger RoutedEvent="Binding.SourceUpdated" >
<BeginStoryboard>
<Storyboard Storyboard.TargetProperty="Foreground">
<ColorAnimation From="Black"
To="Red"
AutoReverse="True"
RepeatBehavior="3"
Duration="0:0:2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
【问题讨论】: