是否有可能在一次动画多的TextBlocks颜色变化? [英] Is it possible to Animate a color change on multiple textblocks at once?

查看:255
本文介绍了是否有可能在一次动画多的TextBlocks颜色变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用一个页面的Windows Phone 7应用程序和一个StackPanel中的页面上。

I've to a Windows Phone 7 app with a page and a StackPanel on that page.

该StackPanel中包含几个TextBlock的元素。

The StackPanel contains several TextBlock elements.

我需要所有的动画将TextBlock元素的颜色是一样的。

I need to animate the color of ALL the TextBlock elements the same way.

不幸的是,当我设置了一个ColorAnimationUsingKeyFrames,我只能指定一个单一的TargetName。由于有需要进行动画处理方式相同的多个TextBlock的控制,这是pretty不方便,我怀疑,必须有一个更好的方式来处理这是复制粘贴ñColorAnimation定义,每个文本块的动画。

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?

编辑:我意识到这是一个问题,WP7,但我已经标记它WPF,因为我相信同样的技术将适用于,但随时纠正我,如果我错了

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.

推荐答案

您应该能够针对你的动画在一个单一的元素的属性,那么使用的ElementName绑定的TextBlocks之间的值同步。或例如:

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:

<TextBlock x:Name="textOne" Text="One"/>
<TextBlock x:Name="textTwo" Text="Two"
           Background="{Binding Background, ElementName=textOne}"/>

在上面的XAML有一个 TextBlock的背景绑定到其他。如果你的故事板目标的textOne',那么其他的TextBlock 也将动画。

In the above XAML the background of one TextBlock is bound to the other. If your storyboard targets 'textOne', then the other TextBlock will animate also.

这篇关于是否有可能在一次动画多的TextBlocks颜色变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆