2
我在嘗試在Silverlight應用中設置LinearGradientBrush(lgb)的動畫效果。我在頁面的構造函數中有以下代碼:在代碼背後動畫LinearGradientBrush顏色
for (int stops = 0; stops < numStops; stops++)
{
ColorAnimation animation = new ColorAnimation();
animation.To =
Color.FromArgb(255, (byte)rnd.Next(256), (byte)rnd.Next(256), (byte)rnd.Next(256));
animation.Duration = TimeSpan.FromSeconds(1);
Storyboard.SetTarget(animation, lgb);
Storyboard.SetTargetProperty(animation,
new PropertyPath("GradientStops[" + stops.ToString() + "].Color"));
Storyboard story = new Storyboard();
story.Children.Add(animation);
story.Begin();
}
它編譯並運行,但不更改顏色。我只是不明白我做錯了什麼。
謝謝
WTS
我會寫一個測試應用程序在3和4中「當我有時間時」,並回到你身邊...... – 2011-02-17 14:13:04