Silverlight 中使用动态值的动画

发布于 2024-08-14 20:02:57 字数 979 浏览 2 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2024-08-21 20:02:57

这篇文章介绍了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 an x: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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文