WPF对某个元素进行淡入淡出

作者: 吴杰 分类: 编程 发布时间: 2016-12-15 16:40

WPF对某个元素进行淡入淡出,例如对 ImagePage 元素进行淡入淡出,代码如下:

淡入

daV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(1)));
this.ImagePage.BeginAnimation(UIElement.OpacityProperty, daV);

淡出

DoubleAnimation daV = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(1)));
this.ImagePage.BeginAnimation(UIElement.OpacityProperty, daV);