I'm using a TextBlock in a datatemplate for a cell in a datagrid. I have a requirement that says when the value of the cell changes, the text should:
- fade out before changing
- value should change
- fade back in again
At the moment I use the TargetUpdated RoutedEvent to trigger an animation to make the text fade away and then come back. But the fade happens after the text has already changed value on screen.
<DataTemplate>
<Border>
<TextBlock Name="templateTextBlock" Text="{Binding Path=FirstName, NotifyOnTargetUpdated=True}" />
</Border>
<DataTemplate.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard AutoReverse="True">
<DoubleAnimation Storyboard.TargetName="templateTextBlock" Storyboard.TargetProperty="Opacity" To=".1" Duration="0:0:.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</DataTemplate.Triggers>
</DataTemplate>
My question is how do I achieve the effect required - fade out, change text, fade in?
Many thanks.