I’ve to a Windows Phone 7 app with a page and a StackPanel on that page.
The StackPanel contains several TextBlock elements.
I need to animate the color of ALL the TextBlock elements the same way.
Unfortunately, when I set up a ColorAnimationUsingKeyFrames, I can only specify a single TargetName. Since there are multiple TextBlock controls that need to be animated the same way, that’s pretty inconvenient, and I suspect there has to be a better way to handle this that copy pasting n ColorAnimation definitions, one for each textblock to animate.
Any ideas how to set up a color animation to apply to multiple controls at once?
EDIT: I realize this is a WP7 question, but I’ve tagged it WPF, since I believe the same technique would apply to both, but feel free to correct me if I’m wrong.
You should be able to target your animation at the property of a single element, then use ElementName binding to synchronize values between TextBlocks. or example:
In the above XAML the background of one
TextBlockis bound to the other. If your storyboard targets ‘textOne’, then the otherTextBlockwill animate also.