2011-08-14 93 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 –