Alex Rivera | Logout

WPF TextBlock text changed notify

Asked 2010-06-03T05:56:24.760
18

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.

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>

Using the mouse enter event the text flash is fine but using the Binding.TargetUpdated event didn't trigger anything.

Anyone know about event that raise when the TextBlock text is changed ?

Edit
Report

1 Answer

30

did you set the NotifyOnTargetUpdated property to true

<TextBlock Text="{Binding Path=YourProperty, NotifyOnTargetUpdated=True}" TargetUpdated="OnTargetUpdated"/>
answered 2010-06-03T09:34:44.757

Your Answer