I'm trying to trigger an animation declared in the window's XAML file from the window's vb code when an event is raised (calling a function), like a window's "loaded" event.
Here's how I declare the animation (as a storyboard):
Dim StartAnimation As Storyboard = DirectCast(FindName("ServiceOn"), Storyboard)
Dim StopAnimation As Storyboard = DirectCast(FindName("ServiceOff"), Storyboard)
And here's the code for the function that is failing:
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
The error that I'm getting is the following:
"Value cannot be null. Parameter name: storyboard"
It looks like it's missing something right after "Button1.BeginStoryboard(StartAnimation,...)
Any ideas?