我试图在引发事件(调用函数)时从窗口的 vb 代码触发在窗口的 XAML 文件中声明的动画,例如窗口的“加载”事件。
这是我声明动画的方式(作为故事板):
Dim StartAnimation As Storyboard = DirectCast(FindName("ServiceOn"), Storyboard)
Dim StopAnimation As Storyboard = DirectCast(FindName("ServiceOff"), Storyboard)
这是失败的函数的代码:
Public Function CheckStatus() As Boolean
If sControl.Status = ServiceControllerStatus.Running Then
Me.Button1.Content = "Stop"
Button1.BeginStoryboard(StartAnimation, HandoffBehavior.Compose, isControllable:=False)
ElseIf sControl.Status = ServiceControllerStatus.Stopped Then
Me.Button1.Content = "Start"
Button1.BeginStoryboard(StopAnimation, HandoffBehavior.Compose, isControllable:=False)
End If
End Function
我得到的错误如下:
“值不能为空。参数名称:情节提要”
看起来它在“Button1.BeginStoryboard(StartAnimation,...)
有任何想法吗?