开发者

Animation in Silverlight using a dynamic value

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:

<开发者_StackOverflowEasingDoubleKeyFrame 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜