同样的动画多目标名称

编程入门 行业动态 更新时间:2024-10-26 20:22:04
本文介绍了同样的动画多目标名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

只是一个doubt.I在我的WPF application.Im三个图像会给出三个images.So我为这个code眨眼的效果。

Just a doubt.I have three images in my WPF application.Im going to give blink effect for that three images.So i gave this code.

<Storyboard x:Key ="AlarmBlink"> <DoubleAnimation Storyboard.TargetName="Img1" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:0.1" AutoReverse="True" RepeatBehavior="Forever" /> </Storyboard>

这一个是FirstImage(IMG1)。所以我不得不放弃了另外两个images.Can我给在previus编码多个taget名。否则,我要复制并粘贴samecoding和改变TARGETNAME。有什么办法在单编码给?

This one is for FirstImage(Img1).So i have to give for other two images.Can i give multiple taget name in previus coding. Otherwise i have to copy and paste the samecoding and changing targetname. Is there any way to give in single coding?

推荐答案

您不能把多个Storyboard.TargetNames在DoubleAnimation是,但有一个更好的办法:使用数据绑定三个不透明度值绑定在一起,然后进行动画只有一个他们与其他人将发生变化。

You cannot put multiple Storyboard.TargetNames in a DoubleAnimation, but there is a better way: Use data binding to bind the three Opacity values together, then animate just one of them and the others will change as well.

请注意:为了避免在创建绑定的不对称性可能要使用此附加tecnhique:

Note: To avoid asymmetry in creating your bindings you may want to use this additional tecnhique:

  • 创建第四控制能见度=坍塌,所以你永远不会看到它
  • 动画此控件的不透明度
  • 绑定所有的三个可见控件不透明度为无形之一的透明度。
  • 另一种选择是使用一个单一的DoubleAnimation是和使用code后面将它应用到所有三个图像,而不是使用WPF的故事板​​的机制。这给了你更多的控制,但需要您编写C-背后的$ C $。

    Another option is to use a single DoubleAnimation and use code behind to apply it to all three images instead of using WPF's StoryBoard mechanism. This gives you much more control but requires you to write the code-behind.

    一般来说,我坚持与结合溶液,因为它是最简单的。在任何情况下,剪切和粘贴解决方案通常是最糟糕的。

    Generally I stick with the binding solution because it is simplest. In any case the cut-and-paste solution is usually the worst of all.

    更多推荐

    同样的动画多目标名称

    本文发布于:2023-11-05 19:32:25,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1561660.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:名称   目标   动画

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!