Animating multiple items or repeating the same thing

2 posts, 0 answers
  1. Chandra
    Chandra avatar
    1 posts
    Member since:
    Mar 2013

    Posted 08 Sep 2013 Link to this post

    I am animating my text right now, in this manner.  

    I want to do couple of things :

    1) play animation repeatedly until user action    --> this didnt work when I called the animate(), one after another.  
    2) animate different text strings one after another. - when I tried to animate 3 textblocks one after another, they all played at same time. Also, with sleep 500 secs between them, they still started same time.

    Is there any sample code you can provide here ?

    In XAML:

                <telerikCore:RadScaleAnimation x:Key="radScaleAnimation" Duration="0:0:2" AutoReverse="True"/>
                            <TextBlock Name="target1"  Text="Congratulations !" Margin="10" TextWrapping="Wrap" 
                                   FontSize="{StaticResource PhoneFontSizeMedium}" Foreground="Red" />

    In CS file : 

    void animate()
    {              scaleAnimation = this.LayoutRoot.Resources["radScaleAnimation"] as RadScaleAnimation;
                    scaleAnimation.StartScaleX = 0.5;
                    scaleAnimation.EndScaleX = 4;
                    scaleAnimation.StartScaleY = 0.5;
                    scaleAnimation.EndScaleY = 4;
                    EasingFunctionBase ease = new QuadraticEase();
                    ease.EasingMode = EasingMode.EaseInOut;
                    scaleAnimation.Easing = ease;
                     RadAnimationManager.Play(this.target1, scaleAnimation);
  2. Deyan
    Deyan avatar
    2026 posts

    Posted 12 Sep 2013 Link to this post

    Hi Chandra,

    Thanks for writing.

    1. To play an animation repeatedly you need to set the RepeatBehavior property to RepeatBehavior.Forever. This will play the animation until you manually stop it.

    2. To animate elements one after another you need to prepare animation for each element and set the InitialDelay property for each animation so that it starts right after the duration of the previous one is over.
     You do not need to use timers and sleep the UI thread. Just play all animations simultaneously by defining different InitialDelay values for each animation.

    I hope this helps.

    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
Back to Top