如何使动画通过WPF code顺畅? [英] How to make the animation smoother through code in WPF?

查看:322
本文介绍了如何使动画通过WPF code顺畅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们该怎么做了平滑的动画。
我有code如下。

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?

谢谢,

推荐答案

要在code做到这一点,你可以使用<$c$c>Timeline.SetDesiredFrameRate(Timeline,int?)方法是这样的:

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.

这篇关于如何使动画通过WPF code顺畅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆