Question

I have a storyboard that seems to stop randomly by itself, I cannot for the life of me figure out why.

It seems to stop and random intervals.

private void CreateStoryboard(int from)
    {
        int? targetTo;
        Duration dur;
        targetTo = 150;
        dur = 150;

        Int32Animation element = new Int32Animation();
        element.From = from;
        element.To = targetTo;
        element.Duration = dur;
        Storyboard.SetTargetProperty(element, new PropertyPath(CurrentFrameProperty));
        _filmstripStoryboard = new Storyboard {SpeedRatio = this.FrameRate};
        _filmstripStoryboard.Children.Add(element);
        _filmstripStoryboard.Completed += new EventHandler(FilmstripStoryboard_Completed);
         _filmstripStoryboard.Begin(this, true);
    }

As you can see im affecting the custom "CurrentFrameProperty" DP, which has a callback method that I print out the current frame.

For some reason, and I have just no idea why, the storyboard just stops. The completed event does NOT get fired, and the callback method stops getting called.

And I am sure that I am not calling stop() anywhere.

If anyone has had this issue or can help me debug it, I would be very grateful.

Was it helpful?

Solution 2

It was the deconstructors! My objects with a reference to the storyboards and animations were getting destroyed, so the animation just looked like it froze up.

user error :)

OTHER TIPS

Your code should work. I am not sure what the SpeedRatio=this.FrameRate does, but you can easily test your code with that piece removed. My best guess is that some other piece of code is affecting your DpendencyProperty, and that multithreaded code is biting you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top