{"record":{"id":"83b2039b38709e0f","repo":"dotnet/wpf","slug":"storyboard-storyboardreferencerequired","errorCode":"Storyboard_StoryboardReferenceRequired","errorMessage":"SR.Storyboard_StoryboardReferenceRequired","messagePattern":"SR\\.Storyboard_StoryboardReferenceRequired","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/BeginStoryboard.cs","lineNumber":139,"sourceCode":"    // Bug #1329664 workaround to make beta 2\n    // Remove thread affinity when sealed, but before doing that, snapshot the\n    //  current Storyboard value and remove *its* thread affinity too.\n    internal override void Seal()\n    {\n        if( !IsSealed )\n        {\n            // Gets our Storyboard value.  This value may have come from a\n            //  ResourceReferenceExpression or might have been a deferred\n            //  reference that has since been realized.\n            Storyboard snapshot = GetValue(StoryboardProperty) as Storyboard;\n\n            if( snapshot == null )\n            {\n                // This is the same error thrown by Begin if the Storyboard\n                //  property couldn't be resolved at Begin time.  Since we're\n                //  not allowing changes after this point, lack of resolution\n                //  here means the same thing.\n                throw new InvalidOperationException(SR.Storyboard_StoryboardReferenceRequired);\n            }\n            \n            // We're planning to break our thread affinity - we also need to\n            //  make sure the Storyboard can also be used accross threads.\n            if(!snapshot.CanFreeze)\n            {\n                throw new InvalidOperationException(SR.Storyboard_UnableToFreeze);\n            }\n            if(!snapshot.IsFrozen)\n            {\n                snapshot.Freeze();\n            }\n\n            // Promote that snapshot into a local value.  This is a no-op if it\n            //  was a deferred reference or local Storyboard, but if it came from a \n            //  ResourceReferenceExpression it will replace the Expression object\n            //  with a snapshot of its current value.\n            Storyboard = snapshot;","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/BeginStoryboard.cs#L121-L157","documentation":"BeginStoryboard.Seal throws InvalidOperationException (SR.Storyboard_StoryboardReferenceRequired) when the Storyboard property is still null (or its reference could not be resolved) at seal time. Since sealing forbids further changes, an unresolved Storyboard can never be fixed later, so the error matches the one Begin would throw.","triggerScenarios":"Sealing a BeginStoryboard (via sealing the containing TriggerActions collection) whose Storyboard property is null, e.g. a StaticResource lookup that failed so the storyboard reference never resolved.","commonSituations":"XAML Triggers where the Storyboard StaticResource/DynamicResource reference is misspelled or the resource is defined after/outside the reachable scope.","solutions":["Ensure the Storyboard property is set to a valid Storyboard instance before the trigger collection is sealed.","Fix the resource key in XAML so the Storyboard reference resolves (verify StaticResource name and scope).","Define the Storyboard resource earlier in the visual tree (e.g. in Window/Application resources) so resolution succeeds."],"exampleFix":"// before\n<BeginStoryboard Name=\"begin\"/> <!-- Storyboard missing -->\n// after\n<BeginStoryboard Name=\"begin\" Storyboard=\"{StaticResource FadeInStoryboard}\"/>","handlingStrategy":"validation","validationCode":"if (beginStoryboard.Storyboard == null)\n    throw new InvalidOperationException(\"BeginStoryboard.Storyboard must be set before sealing\");","typeGuard":null,"tryCatchPattern":"try { actions.Seal(); }\ncatch (InvalidOperationException ex) { /* log missing Storyboard reference; fix resource key */ }","preventionTips":["Always set Storyboard on BeginStoryboard in XAML triggers","Verify StaticResource keys resolve (define resources in Application/Window scope)","Programmatically check Storyboard != null before adding triggers to templates"],"tags":["wpf","animation","xaml","missing-reference"],"backgroundTag":"missing-dependency","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}