dotnet/wpf · error · InvalidOperationException

Storyboard_BeginStoryboardNameRequired

Storyboard_BeginStoryboardNameRequired

Error message

SR.Storyboard_BeginStoryboardNameRequired

What it means

A ControllableStoryboardAction (PauseStoryboard/ResumeStoryboard/StopStoryboard/SeekStoryboard/SetStoryboardSpeedRatio/SkipToFill) targets a storyboard indirectly by referencing a BeginStoryboard action's Name. WPF throws this InvalidOperationException from GetStoryboard when the action's BeginStoryboardName property was never set, so it cannot look up which BeginStoryboard to use.

Solutions

  1. Set BeginStoryboardName on the control action to the x:Name of the BeginStoryboard element that started the storyboard.
  2. Ensure the BeginStoryboard being referenced has x:Name set and is in the same name scope (same template/page).
  3. If the storyboard should not be controllable, use a plain BeginStoryboard without control actions instead.

Example fix

// before
<EventTrigger RoutedEvent="Button.Click">
  <PauseStoryboard/>
</EventTrigger>

// after (must match BeginStoryboard's x:Name)
<EventTrigger RoutedEvent="Button.Click">
  <PauseStoryboard BeginStoryboardName="myBeginStoryboard"/>
</EventTrigger>
Defensive patterns

Strategy: validation

Validate before calling

bool ok = !string.IsNullOrEmpty(pauseStoryboard.BeginStoryboardName);

Try / catch

try { action.Invoke(fe, fce); } catch (InvalidOperationException ex) { log.Error("Storyboard action missing BeginStoryboardName", ex); }

Prevention

When it happens

Trigger: Declaring <PauseStoryboard/> (or Resume/Stop/Seek/SetSpeedRatio) inside an EventTrigger without setting its BeginStoryboardName attribute, then invoking the trigger.

Common situations: Copy-pasting control actions from templates where the BeginStoryboardName attribute was dropped; writing storyboard-control XAML by hand and not realizing control actions must reference the BeginStoryboard that started the storyboard.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/23c3548ed7f5f2d9. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/ControllableStoryboardAction.cs:95

    internal sealed override void Invoke( FrameworkElement fe )
    {
        Debug.Assert( fe != null, "Invoke needs an object as starting point");

        Invoke( fe, null, GetStoryboard( fe, null, null ) );
    }

    internal virtual void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE,  Storyboard storyboard )
    {
    }

    // Find a Storyboard object for this StoryboardAction to act on, using the
    //  given BeginStoryboardName to find a BeginStoryboard instance and use
    //  its Storyboard object reference.
    private Storyboard GetStoryboard( FrameworkElement fe, FrameworkContentElement fce, INameScope nameScope )
    {
        if( BeginStoryboardName == null )
        {
            throw new InvalidOperationException(SR.Storyboard_BeginStoryboardNameRequired);
        }

        BeginStoryboard keyedBeginStoryboard = Storyboard.ResolveBeginStoryboardName( BeginStoryboardName, nameScope, fe, fce );
        
        Storyboard storyboard = keyedBeginStoryboard.Storyboard;

        if( storyboard == null )
        {
            throw new InvalidOperationException(SR.Format(SR.Storyboard_BeginStoryboardNoStoryboard, BeginStoryboardName));
        }
        
        return storyboard;
    }

    private string     _beginStoryboardName = null;
}
}

View on GitHub (pinned to 81131a70a4)