{"record":{"id":"9897de79043951be","repo":"dotnet/wpf","slug":"storyboard-propertypathempty","errorCode":"Storyboard_PropertyPathEmpty","errorMessage":"SR.Storyboard_PropertyPathEmpty","messagePattern":"SR\\.Storyboard_PropertyPathEmpty","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs","lineNumber":463,"sourceCode":"                        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;\n\n                    if( targetProperty == null )\n                    {\n                        // Unfortunately it's not a DependencyProperty.\n                        throw new InvalidOperationException(SR.Format(SR.Storyboard_PropertyPathMustPointToDependencyProperty, currentPropertyPath.Path ));\n                    }\n\n                    VerifyAnimationIsValid(targetProperty, animationClock);\n\n                    ObjectPropertyPair animatedTarget = new ObjectPropertyPair(targetObject, targetProperty);","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs#L445-L481","documentation":"The timeline's PropertyPath resolved to an empty path: a TargetProperty was supplied (or derived) but its length is 0, so there is no property to animate. ClockTreeWalkRecursive rejects this with an InvalidOperationException because an empty path cannot map to an animatable property.","triggerScenarios":"Setting Storyboard.TargetProperty=\"\" in XAML, or passing an empty/null path to Storyboard.SetTargetProperty in code (new PropertyPath(\"\")).","commonSituations":"Binding TargetProperty from a resource/config value that is empty; dynamically built XAML where the property segment was dropped; refactoring that left an empty attribute in place.","solutions":["Supply a non-empty property path, e.g. Storyboard.TargetProperty=\"Opacity\" or \"(Panel.Background).(SolidColorBrush.Color)\".","In code, pass a PropertyPath with at least one segment.","Validate any dynamically constructed property name for null/empty before beginning the storyboard."],"exampleFix":"// before\nstring prop = GetPropertyFromConfig(); // \"\"\nStoryboard.SetTargetProperty(anim, new PropertyPath(prop)); // throws\n\n// after\nstring prop = GetPropertyFromConfig();\nif (string.IsNullOrEmpty(prop)) prop = \"Opacity\"; // validate before use\nStoryboard.SetTargetProperty(anim, new PropertyPath(prop));","handlingStrategy":"validation","validationCode":"var pp = Storyboard.GetTargetProperty(anim);\nif (pp == null || string.IsNullOrEmpty(pp.Path))\n    throw new InvalidOperationException(\"Storyboard.TargetProperty path is empty\");","typeGuard":"bool HasNonEmptyPath(Timeline t) => Storyboard.GetTargetProperty(t)?.Path is { Length: > 0 };","tryCatchPattern":"try { sb.Begin(fe); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"path\")) {\n    // fix: supply a non-empty PropertyPath\n}","preventionTips":["Validate dynamic/config-driven property names for null/empty before use.","Never assign new PropertyPath(\"\") or null.","Build property strings defensively with a default fallback."],"tags":["wpf","storyboard","propertypath","empty-value"],"backgroundTag":"empty-required-field","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"}