public void Blink() { DoubleAnimation fadingAnimation = new DoubleAnimation(); fadingAnimation.From = 0.6; fadingAnimation.To = 0; fadingAnimation.Duration = new Duration(TimeSpan.FromSeconds(1)); fadingAnimation.RepeatBehavior = RepeatBehavior.Forever; fadingAnimation.Completed += (eSender, eArgs) => { fadingAnimation = new DoubleAnimation(); fadingAnimation.From = 0; fadingAnimation.To = 0.6; fadingAnimation.Duration = new Duration(TimeSpan.FromSeconds(1)); }; BlinkRectangle.BeginAnimation(Image.OpacityProperty, fadingAnimation); }
public void Blink() { var fadingAnimation = new DoubleAnimation { From = 0.6, To = 0, Duration = new Duration(TimeSpan.FromSeconds(1)), RepeatBehavior = RepeatBehavior.Forever }; fadingAnimation.Completed += (eSender, eArgs) => { fadingAnimation = new DoubleAnimation { From = 0, To = 0.6, Duration = new Duration(TimeSpan.FromSeconds(1)) }; }; BlinkRectangle.BeginAnimation(OpacityProperty, fadingAnimation); }