WPF 故事版例子

Storyboard std = new Storyboard();
DoubleAnimation a = new DoubleAnimation();
a.From =0;
a.To =400;
a.AutoReverse = true;
a.Duration = new Duration(TimeSpan.Parse("0:0:3"));
Storyboard.SetTarget(a, this);//给动画指定对象
Storyboard.SetTargetProperty(a,
new PropertyPath(Window.LeftProperty));//给动画指定依赖的属性
//a.Completed += sbd_Completed;
//this.BeginAnimation(Window.TopProperty,a);

DoubleAnimation doubleAnimation = new DoubleAnimation();//实例化一个Double类型的动画
doubleAnimation.From = 100;
doubleAnimation.From = 0;
doubleAnimation.AutoReverse = true;
doubleAnimation.Duration = new Duration(TimeSpan.Parse("0:0:3"));
Storyboard.SetTarget(doubleAnimation, this);//给动画指定对象
Storyboard.SetTargetProperty(doubleAnimation,
new PropertyPath(Window.OpacityProperty));//给动画指定依赖的属性
std.Children.Add(doubleAnimation);
std.Children.Add(a);
std.Completed += sbd_Completed;
std.Begin();

猜你喜欢

转载自www.cnblogs.com/lipengxu/p/10265126.html
WPF