C# 窗口动画运行不平稳

C# 窗口动画运行不平稳,c#,wpf,C#,Wpf,我正在用WPF编写一个C#应用程序,我想在按钮点击事件后添加调整窗口大小的动画。我的问题是,动画的运行不如预期的平滑。在一个空的应用程序上,一切都是好的 double final = 800.0; double initial = 223.0; DoubleAnimation animation = new DoubleAnimation(); animation.Duration = TimeSpan.FromSeconds(1); animation.To = final; if (thi

我正在用WPF编写一个C#应用程序,我想在按钮点击事件后添加调整窗口大小的动画。我的问题是,动画的运行不如预期的平滑。在一个空的应用程序上,一切都是好的

double final = 800.0;
double initial = 223.0;

DoubleAnimation animation = new DoubleAnimation();
animation.Duration = TimeSpan.FromSeconds(1);
animation.To = final;
if (this.Width == final) { animation.To = initial; }

this.BeginAnimation(Window.WidthProperty, animation);
如何使动画平稳运行