如何在代码中设置drophadoweffect的不透明度动画。我在我的UI中动态创建包含图像和文本块的堆栈面板。我对图像应用了drophadoweffect,我想为不透明度设置动画。这就是我所拥有的:
Image img = ch.ChannelLogo; //Create the image for the button
img.Height = channelStackPnl.Height * .66;
DropShadowEffect dSE = new DropShadowEffect();
dSE.Color = Colors.White;
dSE.Direction = 25;
dSE.ShadowDepth = 10;
dSE.Opacity = .40;
img.Effect = dSE;
DoubleAnimation animateOpacity = new DoubleAnimation();
animateOpacity.From = 0;
animateOpacity.To = 1;
animateOpacity.AutoReverse = true;
animateOpacity.RepeatBehavior = RepeatBehavior.Forever;
animateOpacity.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 400));
//Here's where I am stuck. How do I specifically target the opacity of the effect propery?
img.BeginAnimationimg.BeginAnimation(DropShadowEffect.OpacityProperty,animateOpacity);
答案 0 :(得分:1)
dSE.BeginAnimation(DropShadowEffect.OpacityProperty, animateOpacity);
...大概
(你是动画效果,而不是图像)