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>
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>