Animating the Opacity property is possible to achieve the fade in&out effect.
The source & bits can be downloaded from here.
The following is the C# code used, #region Fade in
// Create a storyboard to contain the animations.
Storyboard storyboard = new Storyboard();
TimeSpan duration = new TimeSpan(0, 0, 1);
// Create a DoubleAnimation to fade the not selected option control
DoubleAnimation animation = new DoubleAnimation();
animation.From = 0.0;
animation.To = 1.0;
animation.Duration = new Duration(duration);
// Configure the animation to target de property Opacity
Storyboard.SetTargetName(animation, Img1.Name);
Storyboard.SetTargetProperty(animation, new PropertyPath(Control.OpacityProperty));
// Add the animation to the storyboard
storyboard.Children.Add(animation);
// Begin the storyboard
storyboard.Begin(this);
#endregion
The image used comes from here. The executed sample looks like this:
domingo, 28 de enero de 2007
Programmatic Fade In & Out sample
Suscribirse a:
Enviar comentarios (Atom)
4 comentarios:
Thank you very much!
Thanks for sharing. Here's the VB version:
' Create a storyboard to contain the animations.
Dim storyboard As New Storyboard()
Dim duration As New TimeSpan(0, 0, 1)
' Create a DoubleAnimation to fade the not selected option control
Dim animation As New DoubleAnimation()
animation.From = 0.0
animation.To = 1.0
animation.Duration = New Duration(duration)
' Configure the animation to target de property Opacity
storyboard.SetTargetName(animation, Img1.Name)
storyboard.SetTargetProperty(animation, New PropertyPath(Control.OpacityProperty))
' Add the animation to the storyboard
storyboard.Children.Add(animation)
' Begin the storyboard
storyboard.Begin(Me)
And if you want the image to fade in and out repeatedly, just add:
storyboard.RepeatBehavior = RepeatBehavior.Forever()
' and
animation.AutoReverse = True
Pembahasan kali ini teruntuk kamu yang sedang kesulitan login akun sbobet karena muncul keterangan "Sbobet Password Policy". Jangan panik karena kamu hanya diperintahkan untuk Ganti Password Sbobet Online milik (Baca Selengkapnya Disini...)
Publicar un comentario