2011-08-14 61 views
0

我如何去动画代码中的阴影效果的不透明度。我在我的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); 
+0

指向不影响图像。 – Code0987

回答

1
dSE.BeginAnimation(DropShadowEffect.OpacityProperty, animateOpacity); 

大概...

(您设置动画效果,而不是图像)

+0

感谢您花时间回复! – Ben

+0

@Ben:嗯,当然,但它会为你解决吗? –

+0

为什么这不被标记为正确答案? @Ben –