{"record":{"id":"2f38e8d31b609817","repo":"dotnet/wpf","slug":"storyboard-propertypathobjectnotfound","errorCode":"Storyboard_PropertyPathObjectNotFound","errorMessage":"SR.Format(SR.Storyboard_PropertyPathObjectNotFound, AccessorName(path, i-1), path.Path)","messagePattern":"SR\\.Format\\(SR\\.Storyboard_PropertyPathObjectNotFound, AccessorName\\(path, i-1\\), path\\.Path\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs","lineNumber":690,"sourceCode":"    //  not sufficient to mark an intermediate property read-only and\n    //  not-animatable.  In fact, in the current design, it is impossible to\n    //  be 100% sure that something will stay put.\n    internal static void VerifyPathIsAnimatable(PropertyPath path)\n    {\n        object    intermediateObject = null;\n        object    intermediateProperty = null; // Might be DependencyProperty, PropertyInfo, or PropertyDescriptor\n        bool      checkingFrozenState = true;\n        Freezable intermediateFreezable = null;\n\n        for( int i=0; i < path.Length; i++ )\n        {\n            intermediateObject = path.GetItem(i);\n            intermediateProperty = path.GetAccessor(i);\n\n            if( intermediateObject == null )\n            {\n                Debug.Assert( i > 0, \"The caller should not have set the PropertyPath context to a null object.\" );\n                throw new InvalidOperationException(SR.Format(SR.Storyboard_PropertyPathObjectNotFound, AccessorName(path, i-1), path.Path ));\n            }\n\n            if( intermediateProperty == null )\n            {\n                // Would love to throw error with the name of the property we couldn't find,\n                //  but that information is not exposed from the PropertyPath class.\n                throw new InvalidOperationException(SR.Format(SR.Storyboard_PropertyPathPropertyNotFound, path.Path ));\n            }\n\n            // If the first property value is an immutable Freezable, then turn\n            //  off the Frozen state checking - let's hope we can use the cloning\n            //  mechanism for that case.\n            // Index of zero is the path context object itself, one (that we're\n            //  checking here) is the value of the first property.\n            // Example: Property path \"Background.Opacity\" as applied to Button.\n            //  Object 0 is the Button, object 1 is the brush.\n            if( i == 1 )\n            {","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs#L672-L708","documentation":"While validating an animation property path, Storyboard evaluates each intermediate segment with PropertyPath.GetItem; if any intermediate object (other than the root context) is null, VerifyPathIsAnimatable throws this InvalidOperationException naming the accessor that failed and the full path. It means the path could not be walked to a concrete object.","triggerScenarios":"A Storyboard.TargetProperty path whose intermediate segment resolves to null — e.g. a name in the path is not registered, a databound/indexed segment evaluates to null, or the root TargetName resolves to nothing so GetItem(i) returns null.","commonSituations":"Typos in x:Name inside the property path; targeting an element in a DataTemplate whose name is not registered; path segments like (Grid.Children)[0] returning null because the child was not added yet; path referencing a resource or bound value that failed to resolve.","solutions":["Fix the accessor segment reported in the exception (AccessorName) so it resolves to an existing, registered object.","Call RegisterName for any names referenced in the path when building the storyboard in code.","Simplify the property path; avoid segments that can evaluate to null.","Ensure targeted template elements have names registered on the templated parent.","Verify the root TargetName exists before Begin/Apply is called."],"exampleFix":"// before\nstoryboard.SetValue(MediaTimeline.Storyboard.TargetProperty, new PropertyPath(\"(Canvas.Children)[5].(UIElement.Opacity)\"));\n// after\nif (canvas.Children.Count > 5)\n    storyboard.SetValue(MediaTimeline.Storyboard.TargetProperty, new PropertyPath(\"(Canvas.Children)[5].(UIElement.Opacity)\"));","handlingStrategy":"validation","validationCode":"static bool PathResolves(Storyboard sb, FrameworkElement root, string targetName, PropertyPath path)\n{\n    var target = root.FindName(targetName);\n    if (target == null) return false;\n    try { path.Evaluate(target); return true; } catch { return false; }\n}","typeGuard":"bool HasRegisteredName(FrameworkElement root, string name) => root.FindName(name) != null;","tryCatchPattern":"try { storyboard.Begin(target); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"PropertyPath\"))\n{\n    // validate and fix path segments, retry once\n}","preventionTips":["Verify every segment of TargetProperty resolves to a live object","Register names in code-built storyboards","Avoid paths through collections that may be empty at Begin time","Validate template element names are registered before animating"],"tags":["wpf","storyboard","propertypath","animation"],"backgroundTag":"resource-not-found","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"}