//address the storyboard by its name Storyboard sb = (Storyboard)this.FindResource("RectangleAnimation"); //search for the two DoubleAnimationUsingKeyFrames elements in the storyboard DoubleAnimationUsingKeyFrames translate = (DoubleAnimationUsingKeyFrames)sb.Children[0]; DoubleAnimationUsingKeyFrames rotate = (DoubleAnimationUsingKeyFrames)sb.Children[1]; //search for the two splinedoublekeyframe elements in the storyboard SplineDoubleKeyFrame translateFrame = (SplineDoubleKeyFrame)translate.KeyFrames[0]; SplineDoubleKeyFrame rotateFrame = (SplineDoubleKeyFrame)rotate.KeyFrames[0]; //duration: adjust the property keytime to the value of the slider sldDuration translateFrame.KeyTime = new TimeSpan(0, 0, (int)sldDuration.Value); rotateFrame.KeyTime = new TimeSpan(0, 0, (int)sldDuration.Value); //rotation: adjust the property Value of the rotateFrame to he value of te lsider sldrotation rotateFrame.Value = sldRotation.Value; //distance:adjust the property value of the translateFrame to the value of the slider sldDistance translateFrame.Value = sldDistance.Value; //finally start the animation sb.Begin(this);
SplineDoubleKeyFrame translateFrame = (SplineDoubleKeyFrame)translate.KeyFrames[0]; saying: Unable to cast object of type 'System.Windows.Media.Animation.EasingDoubleKeyFrame' to type 'System.Windows.Media.Animation.SplineDoubleKeyFrame'.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)