2017-08-02 113 views
0

我正在嘗試使用DoubleAnimationUsingKeyFrames爲網格的寬度設置動畫效果。我已經知道如何製作一個簡單的線性動畫,但我試圖實現的是一個平滑的運動,它在啓動時加速而不是減速。現在我正在使用LinearDoubleKeyFrame,但我已經嘗試了所有其他類型的DoubleKeyFrames,並且沒有人似乎給我想要的效果。我做了一個graph,應該讓你更好地瞭解我想要得到的東西。WPF平滑動畫

enter image description here

+1

使用一個的['緩動Functions'](https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/緩和函數)。 ['EaseInOut'](https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/media/cubicease-graph.png)看起來離你的圖最近。 –

+0

這就是'CubicEase'的'EaseInOut'模式。 –

+0

感謝您的快速回復,我會在今天晚些時候嘗試這些功能:) –

回答

0

布拉德利Uffner:

使用緩動函數之一。 EaseInOut看起來離您的圖最近。

0

一個例子:

<Trigger.EnterActions> 
    <BeginStoryboard> 
     <Storyboard> 
      <DoubleAnimation To="100" Duration="0:0:0.2" Storyboard.TargetName="e" Storyboard.TargetProperty="Width"> 
      <DoubleAnimation.EasingFunction> 
       <EaseInOut ></EaseInOut > 
      </DoubleAnimation.EasingFunction> 
      </DoubleAnimation> 
     </Storyboard> 
    </BeginStoryboard> 
</Trigger.EnterActions>