Here is the C # code version for those who need it ...
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(); }
On the other hand, you can implement blinking for any control like this.
<UserControl.Resources> <Thickness x:Key="ControlMargin">0 5 0 0</Thickness> <Storyboard x:Key="AlertArea" > <DoubleAnimation Storyboard.TargetName="gdPersonData" Storyboard.TargetProperty="Opacity" From="0" To="1" RepeatBehavior="3x" AutoReverse="True" Duration="0:0:0.1"/> </Storyboard> <Storyboard x:Key="AlertArea2" > <DoubleAnimation Storyboard.TargetName="gdPersonData" Storyboard.TargetProperty="Opacity" From="1" To="0" RepeatBehavior="1x" AutoReverse="True" Duration="0:0:0.1"/> </Storyboard> </UserControl.Resources>
AlertArea should generate a blink 3 times, and when it is finished, we need to restore Opacity with AlertArea2 .
In the constructor of UserControl/Window
.. Storyboard sb = this.FindResource("AlertArea") as Storyboard; sb.Completed += Sb_Completed; .. private void Sb_Completed(object sender, EventArgs e) { Storyboard sb2 = this.FindResource("AlertArea2") as Storyboard; sb2.Begin(); }
At this point you need to start flashing, do it
Dispatcher.BeginInvoke((Action)(() => { Storyboard sb = this.FindResource("AlertArea") as Storyboard; sb.Begin(); }));
Developer
source share