Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将以下动画应用于我的窗口:
var ani = new DoubleAnimation(610, TimeSpan.FromSeconds(0.7)); BeginAnimation(Window.WidthProperty, ani);
问题是这个动画只有第一次有效,其他时候没有效果。 为什么?我该如何解决这个问题?
您必须在创建DoubleAnimation(作为第一个参数)时指定 fromValue。
DoubleAnimation
var ani = new DoubleAnimation(ActualWidth, 610, TimeSpan.FromSeconds(0.7));
您可以添加以下代码:
ani.RepeatBehavior = RepeatBehavior.Forever;
RepeatBehavior动画将在设置为 Forever完成后自行重复
RepeatBehavior