Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Animation Question - Changing Endpoint Programatically
4 replies. Latest Post by Mog Liang - MSFT on July 5, 2009.
(0)
Status
Member
23 points
56 Posts
06-29-2009 11:37 AM |
I have a question about changing an endpoint for an existing animation programatically. I have a circle that does some animation (skew, resizing...etc) from it's current position to X,Y in a set amount of time. Is there an easy way to set the destination X,Y?
nirav_20...
274 points
105 Posts
07-02-2009 6:10 AM |
You can access DoubleAnimationKeyFrame for starting frame and the same for the ending frame.
You can get the DoubleAnimationKeyFrame for end frame as
DoubleAnimationKeyFrame endKeyFrameInstance=StoryboardObject.Children[StoryboardObject.Children.Count-1];
set end value as
endKeyFrameInstance.EndValue=someValue;
Regards,
Nirav
07-02-2009 6:21 PM |
I've been doing something similar. Not sure what a DoubleAnimationKeFrame is though. My transform animation is a DoubleAnimationUsingKeyFrames with SplineDoubleKeyFrames within it. The ending value is correct, but it's not animating to the correct spot, it's 1/2 the value it should be.
<Storyboard x:Name="animate">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="puck" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" BeginTime="00:00:00"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/> <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0"/> <SplineDoubleKeyFrame x:Name="endY" KeyTime="00:00:01" Value="0"/> </DoubleAnimationUsingKeyFrames>
</Storyboard>
Code:
DoubleAnimationUsingKeyFrames daukf2 = (DoubleAnimationUsingKeyFrames)animateUp.Children[3]; daukf2.KeyFrames[0].Value = startingYloc; // starting point daukf2.KeyFrames[1].Value = halfY; // halfway point daukf2.KeyFrames[2].Value = modYloc; // Ending point
egoZd
326 points
125 Posts
07-05-2009 1:08 AM |
Here i have a full example with source talk about how to dymtic set up the endpoint for animation!
http://www.slblogger.cn/p66.htm
Mog Lian...
All-Star
15864 points
1,541 Posts
07-05-2009 11:53 PM |
Hi Status,
I understand that you applied a group of Transform on animation target. The problem you encountered is TranslateTransform isn't precise, it cannot translate target to correct place. If I misunderstood you, please correct me.
From your description, I assume that you used ScaleTransform. When using ScaleTransform, the actual translate distance is
This may be the reason why animation target doesn't move enough distance as TranslateTransform's property set. Could you confirm this?
For more information about Transform, please check this article
http://msdn.microsoft.com/en-us/library/cc189037(VS.95).aspx
Thanks,