I just ran into this same problem so i figured i'd share my findings.
You get that error when your storyboard is not marked as Controllable. Storyboards are marked as Controllable when the Begin method is called.
If you're doing it from code behind then you just use an overload that has this IsControllable
boolean argument (list of Begin overloads).
If you've used the BeginAnimation element in Xaml then you'll need to do 2 things.
- assign a
Name
to the BeginAnimation element. The documentation for this property states: "If the Name of BeginStoryboard is unspecified, the Storyboard cannot be interactively affected after it is begun"
- When you're trying to interact with your storyboard in codebehind you must pass in the reference to the object that your BeginStoryboard was declared in.
Here's an example showing you step 1 (name the beginstoryboard)
<Button Name="btn1" Content="bla">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard
Name="bnt1_beginStoryboard"
Storyboard={StaticResource someSharedStoryboard}"/>
</EventTrigger>
</Button.Triggers>
</Button>
and here's an example for step 2. Since you've named your beginStoryboard you can use that as a local variable in your class.. or you can just reference the actual storyboard directly. The main point is that you must pass in the owner of the beginStoryboard (which is the button in this case)
//The main point here is that we're passing in btn1
bnt1_beginStoryboard.Storyboard.Stop(btn1);
bnt1_beginStoryboard.Storyboard.SkipToFill(btn1);
bnt1_beginStoryboard.Storyboard.Resume(btn1);
Here's a list of all the "action" methods on a storyboard that require you to pass in the owning framework element: Control a Storyboard After It Starts