Imports System.Windows.Media.Animation
Public Class UserControl1
Private storyboard As New Storyboard()
Private duration As New TimeSpan(0, 0, 2)
Private animation As New DoubleAnimation()
Private Sub Image1_MouseEnter(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles Image1.MouseEnter
Try
Me.Image1.Opacity = 1.0
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Sub FadeIn()
storyboard.AutoReverse = False
animation.From = 0.0
animation.To = 0.5
animation.Duration = New Duration(Duration)
Storyboard.SetTargetName(animation, Me.Image1.Name)
Storyboard.SetTargetProperty(animation, New PropertyPath(UIElement.OpacityProperty))
Storyboard.Children.Add(animation)
storyboard.Begin(Me.Image1)
End Sub
End Class
|