我rotating
在button
at click
,180 degree
它的工作正常
AnimationServices.RotationAnimation((FrameworkElement)sender, 180, 1, "Y"); // working
但是当我以 90 度角用rotating
它两次做同样的事情时,它就不起作用了
AnimationServices.RotationAnimation((FrameworkElement)sender, 90, 1, "Y");
AnimationServices.RotationAnimation((FrameworkElement)sender, 90, 1, "Y"); // not working
它只有rotating
一个90 degree
角度
有人对这个奇怪的问题有任何想法吗?
更新
internal static void RotationAnimation(FrameworkElement sender, int Angle, int DurationInMSec, String Axis)
{
var storyboard = new Storyboard();
var easingDoubleKeyFrame1 = new EasingDoubleKeyFrame
{
KeyTime = TimeSpan.FromMilliseconds(0),
Value = 0
};
var easingDoubleKeyFrame2 = new EasingDoubleKeyFrame
{
KeyTime = TimeSpan.FromMilliseconds(DurationInMSec),
Value = Angle
};
var doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
doubleAnimationUsingKeyFrames.KeyFrames.Add(easingDoubleKeyFrame1);
doubleAnimationUsingKeyFrames.KeyFrames.Add(easingDoubleKeyFrame2);
var rotateTransform = new PlaneProjection();
var button = (FrameworkElement)sender;
button.Projection = rotateTransform;
Storyboard.SetTarget(doubleAnimationUsingKeyFrames, rotateTransform);
Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames, new PropertyPath("Rotation" + Axis));
storyboard.Children.Add(doubleAnimationUsingKeyFrames);
storyboard.Begin();
}