我有這段代碼,不知道如何禁用動畫。如何禁用WPF動畫
任何線索?謝謝!
#region Blinking Animation
Storyboard sb = new Storyboard();
if (IsImageBlinking)
{
DoubleAnimation da = new DoubleAnimation();
da.From = 1.0;
da.To = 0.0;
da.RepeatBehavior = RepeatBehavior.Forever;
da.AutoReverse = true;
sb.Children.Add(da);
Storyboard.SetTargetProperty(da, new PropertyPath("(Image.Opacity)"));
Storyboard.SetTarget(da, image1);
sb.Begin();
}
else // This code doesn't disable the animation :(
{
//!!!! Here I need to disable the animation.
sb.Stop();
sb.Children.Clear();
}
#endregion
什麼時候你想禁用動畫? – lionheart 2012-08-01 13:52:38
@lionheart after else // – 2012-08-01 13:55:10
您是否意識到每次調用此代碼時都會創建* new * Storyboard的事實? – Clemens 2012-08-01 13:56:09