动画

PIPTWY / 2023-05-13 / 原文

using System.Windows.Media.Animation;

 

DoubleAnimation doubleAnimation = new DoubleAnimation();//声明对象
// doubleAnimation.By //原来的基础上操作
doubleAnimation.From //设置动画的初始值
doubleAnimation.To //设置动画的结束值
doubleAnimation.Duration = TimeSpan.FromSeconds();//设置动画的持续时间
doubleAnimation.AutoReverse = true;//是否往返执行
doubleAnimation.RepeatBehavior = new RepeatBehavior();// RepeatBehavior.Forever;//执行周期
doubleAnimation.Completed += Animation_Completed;
button.BeginAnimation(Button.WidthProperty, doubleAnimation);//在当前按钮上执行该动画