Skip to main content

Microsoft Silverlight

Answered Question Animation Question - Changing Endpoint ProgramaticallyRSS Feed

(0)

Status
Status

Member

Member

23 points

56 Posts

Animation Question - Changing Endpoint Programatically

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?

 

I have been playing with using a DoubleAnimationUsingKeyFrames on the animation, but my end point never ends in the correct place (the end keyFrame, always the next to last key frame). 

nirav_2052003
nirav_20...

Member

Member

274 points

105 Posts

Re: Animation Question - Changing Endpoint Programatically

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

 

Status
Status

Member

Member

23 points

56 Posts

Re: Animation Question - Changing Endpoint Programatically

 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
egoZd

Member

Member

326 points

125 Posts

Re: Re: Animation Question - Changing Endpoint Programatically

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

 

Something remember ,Something forgot!


www.douziwang.cn

(My Silverlight Blog Jet,Silverlight game ect.)

Mog Liang - MSFT
Mog Lian...

All-Star

All-Star

15864 points

1,541 Posts

Answered Question

Re: Animation Question - Changing Endpoint Programatically

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

  • [actual distance] = [translate property value] * [scale ratio]

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,

 

Mog Liang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities