Lázár Zsolt
Lázár Zsolt

Reputation: 823

WPF smooth animations

I'm trying to animate a grid's width using DoubleAnimationUsingKeyFrames. I already know how to make a simple linear animation, but what I'm trying to achieve is a smooth movement that speeds up when it starts than slows down at the end. Right now I'm using LinearDoubleKeyFrame, but I've tried all the other types of DoubleKeyFrames, and none seemed to give me the effect I want. I made a graph that should give you a better idea of what I'm trying to get.

enter image description here

Upvotes: 1

Views: 809

Answers (2)

zamoldar
zamoldar

Reputation: 598

An example:

<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>

Upvotes: 1

L&#225;z&#225;r Zsolt
L&#225;z&#225;r Zsolt

Reputation: 823

Bradley Uffner:

Use one of the Easing Functions. EaseInOut looks the closest to your graph.

Upvotes: 1

Related Questions