2010-09-15 49 views

回答

5

這裏是我如何做到這一點: -

 DoubleAnimationUsingKeyFrames compassRoseAnimation = new DoubleAnimationUsingKeyFrames(); 
     compassRoseAnimation.Duration = new Duration(TimeSpan.FromSeconds(2)); 
     QuarticEase easingFunction = new QuarticEase(); 
     easingFunction.EasingMode = EasingMode.EaseInOut; 
     EasingDoubleKeyFrame startAnimation = new EasingDoubleKeyFrame(previousRotationDegrees, KeyTime.FromPercent(0)); 
     EasingDoubleKeyFrame endAnimation = new EasingDoubleKeyFrame(newRotationDegrees, KeyTime.FromPercent(1.0), easingFunction); 
     compassRoseAnimation.KeyFrames.Add(startAnimation); 
     compassRoseAnimation.KeyFrames.Add(endAnimation); 

     RotateTransform rotateTransform = new RotateTransform(); 
     CompassWithNumbersControl.RenderTransform = rotateTransform; 
     rotateTransform.BeginAnimation(RotateTransform.AngleProperty, compassRoseAnimation); 
-1

我已經搞清楚了。我在尋找Easing屬性,但實際上它被稱爲KeySpline,我必須使用DoubleAniamtionUsingKeyFrames來獲得緩動功能。

+1

您不必在所有使用關鍵幀 - 有是兩個完全有效的答案,你沒有把功勞歸功於你,而是用一個壞的解決方案回答你自己的問題。你們的社區相互影響很差。原來的問題也措辭不佳,定義不清/受到限制,沒有任何示例代碼可以證明您的問題。 – tpartee 2014-07-28 23:21:27

6

這是沒有必要使用DoubleAnimationUsingKeyFrames它可以只用DoubleAnimation來完成:

CircleEase easing = new CircleEase(); // or whatever easing class you want 
easing.EasingMode = EasingMode.EaseInOut; 
DoubleAnimation scrollQueue = new DoubleAnimation(); 
scrollQueue.By = -singleScrollAmt; 
scrollQueue.EasingFunction = easing; 
scrollQueue.Duration = TimeSpan.FromSeconds(0.5); 
MyTextBlock.BeginAnimation(Canvas.TopProperty, scrollQueue);