Can't stop StoryBoard

I am creating an animation in procedural code. Nothing fancy, it just rotates a canvas.

I initiate the animation like this

TheAnimation.From = 0;

TheAnimation.To = 360;

TheAnimation.RepeatBehavior =RepeatBehavior.Forever;

TheAnimation.Duration =newDuration(TimeSpan.FromMilliseconds(2000));// 2 secs per revolution

SpinCanvas.BeginStoryboard(TheStoryboard);

How can I stop it?

The sample code in the SDK (How to: Control a Storyboard After It Starts) suggests that this will do the trick, but no dice.

TheStoryboard.Stop(SpinCanvas);

Is it taking me too literally on the "Forever" part?

Thanks

NIK

[1222 byte] By [NickNotYet] at [2007-12-21]
# 1

The problem is not in the Stop(), but in the Begin().

Note that you are not launching the Storyboard the same way as the sample code in http://windowssdk.msdn.microsoft.com/en-us/ms741997(VS.80).aspx

The critical missing part is: In order for Stop() to work, a Storyboard must be launched with Interactive Control set to true.

To modify your program so that it matches the "How To" article's sample code, change the Storyboard Begin call to become:

TheStoryboard.Begin(SpinCanvas, true);

RogerChengMSFT at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

You're absolutely correct

Thank you

NIK

NickNotYet at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified