我有这段代码,无法弄清楚如何禁用动画。
有什么线索吗?谢谢!
#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