2017-08-02 110 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>