当用户将鼠标悬停在按钮上时,我正在尝试使图像淡入/淡出。当我进入按钮时,fadein工作,但是当我离开时,fadein不工作。我怎样才能做到这一点?
动画代码:
Private Sub GreenBg_animation()
Dim myduration As Duration = New Duration(TimeSpan.FromMilliseconds(250))
Dim da As DoubleAnimation = New DoubleAnimation
da.Duration = myduration
Dim sb As Storyboard = New Storyboard
sb.Duration = myduration
sb.Children.Add(da)
Storyboard.SetTarget(da, btn_bg_green)
Storyboard.SetTargetProperty(da, New PropertyPath(OpacityProperty))
da.From = 0.0
da.To = 1.0
da.AutoReverse = True
sb.Begin()
End Sub
按键代码:
Private Sub btn_2_MouseEnter(sender As Object, e As System.Windows.Input.MouseEventArgs) Handles btn_2.MouseEnter
GreenBg_animation()
End Sub
答案 0 :(得分:0)
你需要MouseExit
上的另一个(反向)动画,如果你认为AutoReverse
会为你做那件事你就错了。