2014-11-23 43 views
0

我試圖創建一個非常簡單的動畫,其中我使用C#爲控件上的DropShadowEffect設置了動畫效果。從我對WPF的一點理解,我相信它是這樣做的;在控件上設置DropShadowEffect的動畫效果

 DoubleAnimation da = new DoubleAnimation(); 
     da.From = 10; 
     da.To = 50; 
     da.Duration = TimeSpan.FromSeconds(1); 
     progressBar1.BeginAnimation(DropShadowEffect.BlurRadiusProperty, da); 

這是一個黑色背景上的明亮的彩色光芒,所以我敢肯定發光在那裏,並沒有移動。我試過將它應用於不同的控件。我錯過了明顯的東西嗎? 但代碼完全沒有。我也沒有得到任何錯誤。我將不勝感激任何幫助。

回答

1

你要呼籲的效果,而不是在控制BeginAnimation功能:

這是XAML:

<ProgressBar Width="200" Height="30" Name="progressBar1"> 
    <ProgressBar.Effect> 
     <DropShadowEffect Color="Black" x:Name="effect" > 

     </DropShadowEffect> 
    </ProgressBar.Effect> 
</ProgressBar> 

這裏是代碼:

DoubleAnimation da = new DoubleAnimation(); 
da.From = 10; 
da.To = 50; 
da.Duration = TimeSpan.FromSeconds(1); 
effect.BeginAnimation(DropShadowEffect.BlurRadiusProperty, da); 
+0

啊!我知道我錯過了一些明顯的東西,謝謝你爲我澄清這一點。它現在有效。 – Stella 2014-11-23 14:42:00

相關問題