1

I'm trying to spin a TextBlock 360 degrees whenever it's binding updates.

From everything I've read the following should work, however it doesn't have any effect. What am I doing wrong?

<TextBlock VerticalAlignment="Center" Text="{Binding Total, NotifyOnTargetUpdated=True}">

    <TextBlock.RenderTransform>
        <RotateTransform x:Name="TotalSpinTransform" Angle="0"/>
    </TextBlock.RenderTransform>

    <TextBlock.Triggers>
        <EventTrigger RoutedEvent="Binding.TargetUpdated">
            <EventTrigger.EnterActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetProperty="(TextBlock.RenderTransform).(RotateTransform.Angle)" 
                            From="0" To="360" Duration="0:0:0.2" AutoReverse="True"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.EnterActions>
        </EventTrigger>
    </TextBlock.Triggers>

</TextBlock>       
chillitom
  • 24,888
  • 17
  • 83
  • 118

1 Answers1

4

Neither EnterActions nor ExitActions are applicable to EventTrigger. Unfortunately, these properties are defined on TriggerBase so they are present on an EventTrigger. Try this:

    <EventTrigger RoutedEvent="Binding.TargetUpdated">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(TextBlock.RenderTransform).(RotateTransform.Angle)" 
                        From="0" To="360" Duration="0:0:0.2" AutoReverse="True"/>
                </Storyboard>
            </BeginStoryboard>
    </EventTrigger>
Kent Boogaart
  • 175,602
  • 35
  • 392
  • 393
  • Ha... I didn't even notice it was EnterAction... I just assumed Action (which is what I had in my solution) and mocked up a sample by putting it in a style instead. Good call though! – Scott Mar 04 '11 at 20:30