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

问题描述

我们如何制作流畅的动画.我有如下代码.

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?

谢谢,

推荐答案

要在代码中执行此操作,您可以使用 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

为第二个参数传递 null 告诉系统控制帧速率.

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

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

09-06 05:33