11

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, 0), 
        new Duration(new TimeSpan(0, 0, seconds)), FillBehavior.HoldEnd);                  

pdRod.BeginAnimation(Border.MarginProperty, anima);

Its working, but not smooth enough. How to do it smooth?

Thanks,

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Ershad
  • 947
  • 2
  • 20
  • 40
  • Researching I found this: https://www.devexpress.com/Support/Center/Question/Details/Q454031/wpf-modify-built-in-animations-thread-priority It worked wonders for me. – Andrew Nov 25 '19 at 08:22

3 Answers3

13

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.

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
  • 2
    For me setting `Timeline.DesiredFrameRate` on `Animation` didn't work. I had to set it on my `Storyboard` instead. – ghord Dec 31 '14 at 08:53
4

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

Vadim Ovchinnikov
  • 13,327
  • 5
  • 62
  • 90
2

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

Julien Lebosquain
  • 40,639
  • 8
  • 105
  • 117
  • Thanks, but How to set Timeline.DesiredFrameRate for an animaition object/Frameorkelement object. In the above example , how to set ? – Ershad Oct 06 '09 at 11:34