{"record":{"id":"61fc254e8df3767a","repo":"dotnet/wpf","slug":"storyboard-targetpropertyrequired","errorCode":"Storyboard_TargetPropertyRequired","errorMessage":"SR.Format(SR.Storyboard_TargetPropertyRequired, currentTimeline.GetType().ToString())","messagePattern":"SR\\.Format\\(SR\\.Storyboard_TargetPropertyRequired, 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":453,"sourceCode":"                    // (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);\n                }\n\n                VerifyPathIsAnimatable(currentPropertyPath);\n\n                if( currentPropertyPath.Length == 1 )\n                {\n                    // We have a simple single-step property.\n                    targetProperty = currentPropertyPath.GetAccessor(0) as DependencyProperty;","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs#L435-L471","documentation":"ClockTreeWalkRecursive resolved a target object for a timeline but found no property path: Storyboard.TargetProperty was not set. An animation must know which property to animate, so Storyboard.Begin throws an InvalidOperationException identifying the timeline's type.","triggerScenarios":"A child animation (DoubleAnimation, ColorAnimation, etc.) lacks Storyboard.TargetProperty when the storyboard is begun, even if a target name/object was provided.","commonSituations":"Copy-pasting an animation and deleting the TargetProperty line; building animations in code with Storyboard.SetTargetName but forgetting Storyboard.SetTargetProperty; writing TargetProperty as 'Property' by mistake in XAML.","solutions":["Add Storyboard.TargetProperty=\"PropertyName\" to the timeline (e.g. Opacity or (Canvas.Left)).","In code, call Storyboard.SetTargetProperty(animation, new PropertyPath(\"Opacity\")).","Verify the property exists on the target type and use parenthesis syntax for attached/complex paths."],"exampleFix":"// before\nvar anim = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1));\nStoryboard.SetTargetName(anim, \"MyPanel\");\nsb.Children.Add(anim); // no target property\n\n// after\nvar anim = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1));\nStoryboard.SetTargetName(anim, \"MyPanel\");\nStoryboard.SetTargetProperty(anim, new PropertyPath(\"Opacity\"));\nsb.Children.Add(anim);","handlingStrategy":"validation","validationCode":"if (Storyboard.GetTargetProperty(anim) == null)\n    throw new InvalidOperationException(\"Timeline missing Storyboard.TargetProperty\");","typeGuard":"bool HasTargetProperty(Timeline t) => Storyboard.GetTargetProperty(t) != null;","tryCatchPattern":"try { sb.Begin(fe); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(nameof(DoubleAnimation))) {\n    // fix: add Storyboard.TargetProperty\n}","preventionTips":["Set TargetProperty when creating each animation, before adding to the Storyboard.","In code, always pair SetTargetName with SetTargetProperty.","Watch for XAML attribute typos (TargetProperty vs Property)."],"tags":["wpf","storyboard","targetproperty","missing-property"],"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"}