This is a migrated thread and some comments may be shown as answers.

StackOverFlow Exeption when animating

2 Answers 10 Views
Animation
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
slnee
Top achievements
Rank 1
slnee asked on 11 Feb 2015, 01:20 PM
Hi Telerik,
Im trying to reproduce fade Animation in my project.
I have a StackOverflowException when trying to change animated pictures
Here is the Code:
           
RadFadeAnimation fadeAnimation = null;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
 
            fadeAnimation = this.Container.Resources["radFadeAnimation"] as RadFadeAnimation;
            fadeAnimation.Ended += this.fadeAnimation_Ended;
            RadAnimationManager.Play(this.targetElement, fadeAnimation);
        }
 
 int i = 0;
        private void fadeAnimation_Ended(object sender, AnimationEndedEventArgs e)
        {
            i++;
            this.targetElement.Source = new BitmapImage(new
                     Uri("/Images/dalilbg.png", UriKind.Relative));
                RadAnimationManager.Play(this.targetElement, fadeAnimation);
        }
when the exception is thrown thrown : i = 4029 it seems thats because fadeAnimation_Ended is called many times.
Please Help
Regards

2 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 16 Feb 2015, 12:01 PM
Hello,
 
Could you please try to play the animation asynchronously, because it seems that when you try to play it, it is in invalid state and the ended event fires instantly again.
For example:

this.Dispatcher.BeginInvoke(() =>
    {
        RadAnimationManager.Play(this.targetElement, this.fadeAnimation);
    });

Please, let me know if this helps.


Regards,
Ivaylo Gergov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
slnee
Top achievements
Rank 1
answered on 17 Feb 2015, 10:20 AM
it works fine.
thank you very much
Tags
Animation
Asked by
slnee
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
slnee
Top achievements
Rank 1
Share this question
or