0

I'm trying to do smooth animation in procedural code. For this (in Silverlight at least), it's recommended to use the Storyboard timer rather than a DispatcherTimer. So I use something like this:

    Storyboard _LoopTimer = new Storyboard();
    public void StartAnimation()
    {
        _LoopTimer.Duration = TimeSpan.FromMilliseconds(0);
        _LoopTimer.Completed += new EventHandler(MainLoop);
        _LoopTimer.Begin();
    }
    void MainLoop(object sender, EventArgs e)
    {
        // Do animation stuff here

        // Continue storyboard timer
        _LoopTimer.Begin();
    }

And in Silverlight, this works fine. But in WPF, I only hit MainLoop() once. Setting RepeatBehaviour to Forever doesn't help, either. So what's the right way to do this in WPF with a Storyboard?

Thanks very much.

4

1 に答える 1

0

Silverlight で Storyboard を使用することは、初期のバージョンに DispatcherTimer がなかったことを補うための単なるハックだと思いました。

いずれにせよ、ストーリーボードが終了したら再起動する必要があります。自動的に再起動しません。

于 2010-05-13T06:45:20.840 に答える