{"record":{"id":"23c3548ed7f5f2d9","repo":"dotnet/wpf","slug":"storyboard-beginstoryboardnamerequired","errorCode":"Storyboard_BeginStoryboardNameRequired","errorMessage":"SR.Storyboard_BeginStoryboardNameRequired","messagePattern":"SR\\.Storyboard_BeginStoryboardNameRequired","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/ControllableStoryboardAction.cs","lineNumber":95,"sourceCode":"    internal sealed override void Invoke( FrameworkElement fe )\n    {\n        Debug.Assert( fe != null, \"Invoke needs an object as starting point\");\n\n        Invoke( fe, null, GetStoryboard( fe, null, null ) );\n    }\n\n    internal virtual void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE,  Storyboard storyboard )\n    {\n    }\n\n    // Find a Storyboard object for this StoryboardAction to act on, using the\n    //  given BeginStoryboardName to find a BeginStoryboard instance and use\n    //  its Storyboard object reference.\n    private Storyboard GetStoryboard( FrameworkElement fe, FrameworkContentElement fce, INameScope nameScope )\n    {\n        if( BeginStoryboardName == null )\n        {\n            throw new InvalidOperationException(SR.Storyboard_BeginStoryboardNameRequired);\n        }\n\n        BeginStoryboard keyedBeginStoryboard = Storyboard.ResolveBeginStoryboardName( BeginStoryboardName, nameScope, fe, fce );\n        \n        Storyboard storyboard = keyedBeginStoryboard.Storyboard;\n\n        if( storyboard == null )\n        {\n            throw new InvalidOperationException(SR.Format(SR.Storyboard_BeginStoryboardNoStoryboard, BeginStoryboardName));\n        }\n        \n        return storyboard;\n    }\n\n    private string     _beginStoryboardName = null;\n}\n}\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/ControllableStoryboardAction.cs#L77-L113","documentation":"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.","triggerScenarios":"Declaring <PauseStoryboard/> (or Resume/Stop/Seek/SetSpeedRatio) inside an EventTrigger without setting its BeginStoryboardName attribute, then invoking the trigger.","commonSituations":"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.","solutions":["Set BeginStoryboardName on the control action to the x:Name of the BeginStoryboard element that started the storyboard.","Ensure the BeginStoryboard being referenced has x:Name set and is in the same name scope (same template/page).","If the storyboard should not be controllable, use a plain BeginStoryboard without control actions instead."],"exampleFix":"// before\n<EventTrigger RoutedEvent=\"Button.Click\">\n  <PauseStoryboard/>\n</EventTrigger>\n\n// after (must match BeginStoryboard's x:Name)\n<EventTrigger RoutedEvent=\"Button.Click\">\n  <PauseStoryboard BeginStoryboardName=\"myBeginStoryboard\"/>\n</EventTrigger>","handlingStrategy":"validation","validationCode":"bool ok = !string.IsNullOrEmpty(pauseStoryboard.BeginStoryboardName);","typeGuard":null,"tryCatchPattern":"try { action.Invoke(fe, fce); } catch (InvalidOperationException ex) { log.Error(\"Storyboard action missing BeginStoryboardName\", ex); }","preventionTips":["Always pair controllable storyboard actions with a named BeginStoryboard","Set BeginStoryboardName in XAML immediately when adding Pause/Resume/Stop actions","Review EventTrigger blocks for actions lacking BeginStoryboardName"],"tags":["wpf","xaml","storyboard","animation","missing-attribute"],"backgroundTag":"missing-required-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}