Silverlight 中使用动态值的动画
我想在 Silverlight 中随着时间的推移在 Y 轴上平移一个对象,但它的高度不是恒定的,所以我希望能够将以下内容的第二行从: 更改
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="-50"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0"/>
</DoubleAnimationUsingKeyFrames>
为更像:
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="-100%"/>
或可能:
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="-{ExpandSite Height}"/>
That但是,无法编译。我将不胜感激任何帮助。我使用的是 Expression Blend 3,仅供参考。
编辑
我基本上想要实现类似于此处演示的效果,但此代码理所当然地认为所有正在翻译的对象都是 100x100。
I want to translate an object on its Y-axis over time in Silverlight, but its height is not constant, so I'd like to be able to change the second line of the following from:
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="-50"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0"/>
</DoubleAnimationUsingKeyFrames>
to something more like:
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="-100%"/>
or possibly:
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="-{ExpandSite Height}"/>
That doesn't compile, however. I'd appreciate any help. I'm using Expression Blend 3, for reference.
EDIT
I basically want to achieve an effect similar to what's demonstrated here, but this code takes for granted that all the objects being translated are 100x100.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这篇文章介绍了keyframe元素不继承自framework元素。因此,您无法对其属性进行数据绑定,并且必须在后面的代码中进行更改。
您可以在此处找到如何创建代码隐藏动画的示例。但是,请注意示例代码中存在错误。该代码缺少像
dd.KeyFrames.Add(easy)
这样的行。另一方面,如果您给它一个x:Name
并仅引用数组元素(animation.children[0].KeyFrames[0].Value
可能有效)编辑
我在此网站上发现了另一个帖子确实为您尝试做的事情提供了可能的解决方法,但我自己还没有尝试过。
This article describes that the keyframe element does not inherit from the framework element. Because of that you cannot databind to its properties and will have to do the changes in the code behind.
You can find an example of how to create code-behind animations here. However, just note that there is an error in the sample code. The code is missing a line like
dd.KeyFrames.Add(easy)
. On the other hand, you can most probably access the animation if you give it anx:Name
and just reference the array elements (animation.children[0].KeyFrames[0].Value
might work)EDIT
I found another thread on this site that does provide a possible work around for what you are trying to do, however I have not tried it myself.