I am running multiple animations within a story board, I want to be able to stop them all but I have not had much luck. I have tried: pathAnimationStoryboard.Stop(); pathAnimationStoryboard.FillBehavior = FillBehavior.Stop;
…and a few others to try and control this. Can anyone point me in the right direction. I’m pasting the code to show how I setup the animation sorry it’s a large block. I am animate buttons I create in the code.
pathAnimationStoryboard = new Storyboard();
abuttonMatrixTransform = new MatrixTransform();
bbuttonMatrixTransform = new MatrixTransform();
cbuttonMatrixTransform = new MatrixTransform();
aButton.RenderTransform = abuttonMatrixTransform;
bButton.RenderTransform = bbuttonMatrixTransform;
cButton.RenderTransform = cbuttonMatrixTransform;
this.RegisterName("aButtonMatrixTransform", abuttonMatrixTransform);
this.RegisterName("bButtonMatrixTransform", bbuttonMatrixTransform);
this.RegisterName("cButtonMatrixTransform", cbuttonMatrixTransform);
//Only showing the code for 1 animtion/button now
MatrixAnimationUsingPath matrixAnimation =new MatrixAnimationUsingPath();
matrixAnimation.PathGeometry = animationPath;
matrixAnimation.Duration = TimeSpan.FromSeconds(time);
matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
Storyboard.SetTargetName(matrixAnimation, "aButtonMatrixTransform");
Storyboard.SetTargetProperty(matrixAnimation,
new PropertyPath(MatrixTransform.MatrixProperty));
pathAnimationStoryboard.Children.Add(matrixAnimation);
pathAnimationStoryboard.Begin(this,true);
EDIT This link from Microsoft is basically what I am doing. I am using buttons and sliders to control the speed of the animation or restart it. I am adding new children (to the storyboard) every time, which is a small memory leak. I am not sure what clean up I need to do to remove the old animations. I’m assuming just removing the storyboards children does not work as that does not stop the animations. http://msdn.microsoft.com/en-us/library/ms748831.aspx
Any idea's? Thanks.