{"record":{"id":"9d2ba8e368ceb7f9","repo":"dotnet/wpf","slug":"storyboard-notarget","errorCode":"Storyboard_NoTarget","errorMessage":"SR.Format(SR.Storyboard_NoTarget, currentTimeline.GetType().ToString())","messagePattern":"SR\\.Format\\(SR\\.Storyboard_NoTarget, currentTimeline\\.GetType\\(\\)\\.ToString\\(\\)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs","lineNumber":445,"sourceCode":"                {\n                    DependencyObject mentor = Helper.FindMentor(containingObject);\n\n                    targetObject = ResolveTargetName(currentObjectName, nameScope, mentor);\n                }\n                else\n                {\n                    // The containing object must be either an FE or FCE.\n                    // (Not a Storyboard, as used for \"shared clocks\" mode.)\n                    targetObject = containingObject as FrameworkElement;\n                    if(targetObject == null)\n                    {\n                        targetObject = containingObject as FrameworkContentElement;\n                    }\n\n                    if( targetObject == null )\n                    {\n                        // The containing object is not an FE or FCE.\n                        throw new InvalidOperationException(SR.Format(SR.Storyboard_NoTarget, currentTimeline.GetType().ToString() ));\n                    }\n                }\n            }\n\n            // See if we have a property name to use.\n            if( currentPropertyPath == null )\n            {\n                throw new InvalidOperationException(SR.Format(SR.Storyboard_TargetPropertyRequired, currentTimeline.GetType().ToString() ));\n            }\n\n            // A property name can be a straightforward property name (like \"Angle\")\n            // but may be a more complex multi-step property path.  The two cases\n            // are handled differently.\n            using(currentPropertyPath.SetContext(targetObject))\n            {\n                if( currentPropertyPath.Length < 1 )\n                {\n                    throw new InvalidOperationException(SR.Storyboard_PropertyPathEmpty);","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs#L427-L463","documentation":"ClockTreeWalkRecursive found a timeline with no resolvable target: no Storyboard.TargetName, no Storyboard.Target, and the containing object is not a FrameworkElement/FrameworkContentElement, so no target object can be derived. Storyboard.Begin throws an InvalidOperationException naming the timeline type.","triggerScenarios":"Calling Storyboard.Begin where a child animation lacks both Storyboard.TargetName and Storyboard.Target and there is no implicit containing FE/FCE — e.g. sb.Begin on a non-FE object, or resource-defined storyboards begun without a namescope argument.","commonSituations":"Calling sb.Begin(this) where 'this' is not an FE/FCE; forgetting TargetName on the first animation of a resource-defined storyboard; moving a storyboard from a trigger (which supplied an implicit target) to code-behind without adding TargetName.","solutions":["Add Storyboard.TargetName=\"elementName\" to each timeline (or the parent Storyboard so children inherit).","Or set Storyboard.Target to the actual target DependencyObject in code via Storyboard.SetTarget.","Call Begin on a proper FrameworkElement (window/control) that serves as namescope and containing object."],"exampleFix":"// before\nvar sb = (Storyboard)FindResource(\"fadeSb\");\nsb.Begin(this); // children lack TargetName/Target\n\n// after\nStoryboard.SetTargetName(sb, \"MyPanel\"); // or per-child SetTargetName\nsb.Begin(this);","handlingStrategy":"validation","validationCode":"if (Storyboard.GetTargetName(anim) == null && Storyboard.GetTarget(anim) == null)\n    throw new InvalidOperationException(\"Timeline has no TargetName/Target\");","typeGuard":"bool HasTarget(Timeline t) => Storyboard.GetTargetName(t) != null || Storyboard.GetTarget(t) != null;","tryCatchPattern":"try { sb.Begin(fe); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"no target\") || ex.Message.Contains(nameof(DoubleAnimation))) {\n    // fix: assign Storyboard.TargetName/Target\n}","preventionTips":["Set TargetName on the parent Storyboard so children inherit it.","After moving a storyboard from triggers to code, re-add TargetName/Target.","Only call Begin on FrameworkElement/FrameworkContentElement instances."],"tags":["wpf","storyboard","missing-target","xaml"],"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"}