views:

587

answers:

2

Hello all!

I want to be able to create a fade animation on a text element when the binding to that element updates. In other words, the effect is that as text gets added to a text box one sees a fading effect as the text updates and then fades out. I do'nt know how to achieve this. I have seen something similar using an EventTrigger on a RoutedEvent such as FrameworkElement.Loaded but how does one detect when a binding updates?

Thanks.

+1  A: 

You can set properties on your binding that will cause events to be fired. There are two properties available:

  1. NotifyOnSourceUpdated: Raise the SourceUpdated event when a value is transferred from the binding target to the binding source.
  2. NotifyOnTargetUpdated: Raise the TargetUpdated event when a value is transferred from the binding source to the binding target.

From the description of your setup, it sounds like you want to use NotifyOnTargetUpdated. Set that to true in your binding, then whenever the target updates, the Binding.TargetUpdated event will fire. You can then listen to that event in an EventTrigger, and fade your text.

Charlie
Unfortunately, FrameworkElement.TargetUpdated is not a RoutedEvent and, therefore, cannot be used in an EventTrigger.
HiteshP
Ah- I was very close. You have to use the attached event (Binding.TargetUpdated).
Charlie
+1  A: 

I got this working. The solution can be found here ... http://michaelscherf.wordpress.com/2009/02/23/how-to-trigger-an-animation-when-textblocks-text-is-changed-during-a-databinding/

HiteshP