WPF TextBlock 文本更改通知
我有一个包含大约 15-20 个 TextBlocks 的屏幕,每个 TextBlocks 绑定到不同的属性,起初所有 TextBlocks 都是空的,文本更新来自其他客户端.
I have a screen contain about 15-20 TextBlocks each one bind to a different property, at first all the TextBlocks are empty the text update come from other client.
我想要做的事情是在文本发生变化时动画闪烁文本 3 秒.
The thing I want to do is to animate flashing text for 3 seconds when ever text change.
我使用下面的故事板来实现这一点:
I used the below storyboard to make that happen:
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<EventTrigger RoutedEvent="UIElement.MouseEnter">
<BeginStoryboard >
<Storyboard Duration="0:0:03">
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.5" Value="{x:Static Visibility.Hidden}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:01" Value="{x:Static Visibility.Visible}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:01.5" Value="{x:Static Visibility.Hidden}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:02" Value="{x:Static Visibility.Visible}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:02.5" Value="{x:Static Visibility.Hidden}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:03" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
使用鼠标输入事件文本闪烁很好,但使用 Binding.TargetUpdated
事件没有触发任何东西.
Using the mouse enter event the text flash is fine but using the Binding.TargetUpdated
event didn't trigger anything.
有谁知道当 TextBlock
文本更改时引发的事件?
Anyone know about event that raise when the TextBlock
text is changed ?
您是否设置了 NotifyOnTargetUpdated 属性为 true
did you set the NotifyOnTargetUpdated property to true
<TextBlock Text="{Binding Path=YourProperty, NotifyOnTargetUpdated=True}" TargetUpdated="OnTargetUpdated"/>