我如何去動畫代碼中的陰影效果的不透明度。我在我的UI中動態地創建了包含圖像和文本塊的堆疊面板。我已經對圖像應用了陰影效果,我希望使不透明度成爲動畫效果。下面是我有:如何在C#代碼中設置dropshadoweffect的不透明度?
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);
指向不影響圖像。 – Code0987