StackOverFlow Exeption when animating

3 posts, 0 answers
  1. slnee
    slnee avatar
    18 posts
    Member since:
    Sep 2014

    Posted 11 Feb 2015 Link to this post

    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. Ivaylo Gergov
    Admin
    Ivaylo Gergov avatar
    661 posts

    Posted 16 Feb 2015 Link to this post

    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.

     
  3. DevCraft banner
  4. slnee
    slnee avatar
    18 posts
    Member since:
    Sep 2014

    Posted 17 Feb 2015 Link to this post

    it works fine.
    thank you very much
Back to Top