我想将以下动画应用于“窗口”:

var ani = new DoubleAnimation(610, TimeSpan.FromSeconds(0.7));
BeginAnimation(Window.WidthProperty, ani);


问题在于该动画只能在第一次使用,而在其他时候则没有效果。
为什么?我该如何解决这个问题?

最佳答案

创建DoubleAnimation时必须指定fromValue(作为第一个参数)。

var ani = new DoubleAnimation(ActualWidth, 610, TimeSpan.FromSeconds(0.7));

09-26 15:44