How to make the animation smoother through code in WPF?

前端 未结 3 351
你的背包
你的背包 2020-12-16 17:27

How do we do the smooth animation. I have the code as below.

ThicknessAnimation anima = 
    new ThicknessAnimation(new Thickness(0), new Thickness(0, 25, 0,         


        
相关标签:
3条回答
  • 2020-12-16 18:24

    Try to adjust the attached property Timeline.DesiredFrameRate to your needs. An higher framerate will reduce the tearing you might see.

    0 讨论(0)
  • 2020-12-16 18:26

    To do this in code, you would use the Timeline.SetDesiredFrameRate(Timeline,int?) method, like this:

    ThicknessAnimation anim = ...;
    Timeline.SetDesiredFrameRate(anim, 60); // 60 FPS
    

    Passing null for the second argument tells the system to control the frame rate.

    0 讨论(0)
  • 2020-12-16 18:34

    If you are using StoryBoard, use Timeline.DesiredFrameRate attached property.

    0 讨论(0)
提交回复
热议问题