{"record":{"id":"bf17ee49822781ad","repo":"AvaloniaUI/Avalonia","slug":"cannot-find-property-type-attached-propertyname","errorCode":null,"errorMessage":"Cannot find property {type}.{attached.PropertyName}.","messagePattern":"Cannot find property (.+?)\\.(.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Data/Core/Parsers/ExpressionNodeFactory.cs","lineNumber":117,"sourceCode":"                    new VisualAncestorElementNode(source.AncestorType, source.AncestorLevel - 1),\n                _ => throw new NotSupportedException(\"Unsupported RelativeSource mode.\")\n            };\n        }\n\n        public static ExpressionNode CreateDataContext(AvaloniaProperty? targetProperty)\n        {\n            return targetProperty == StyledElement.DataContextProperty ? \n                new ParentDataContextNode() :\n                new DataContextNode();\n        }\n\n        private static AvaloniaPropertyAccessorNode AttachedPropertyNode(\n            Func<string?, string, Type?>? typeResolver,\n            BindingExpressionGrammar.AttachedPropertyNameNode attached)\n        {\n            var type = LookupType(typeResolver, attached.Namespace, attached.TypeName);\n            var property = AvaloniaPropertyRegistry.Instance.FindRegistered(type, attached.PropertyName) ??\n                throw new InvalidOperationException($\"Cannot find property {type}.{attached.PropertyName}.\");\n            return new AvaloniaPropertyAccessorNode(property);\n        }\n\n        private static LogicalAncestorElementNode LogicalAncestorNode(\n            Func<string?, string, Type?>? typeResolver,\n            BindingExpressionGrammar.AncestorNode ancestor)\n        {\n            Type? type = null;\n\n            if (!string.IsNullOrEmpty(ancestor.TypeName))\n            {\n                type = LookupType(typeResolver, ancestor.Namespace, ancestor.TypeName);\n            }\n\n            return new LogicalAncestorElementNode(type, ancestor.Level);\n        }\n\n        private static Type LookupType(","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Data/Core/Parsers/ExpressionNodeFactory.cs#L99-L135","documentation":"In string/reflection bindings, ExpressionNodeFactory.AttachedPropertyNode resolves an attached property like `(Grid.Row)` by calling AvaloniaPropertyRegistry.Instance.FindRegistered(ownerType, propertyName). If no AvaloniaProperty with that name is registered on the resolved owner type, it throws InvalidOperationException. This is the reflection-binding code path; compiled bindings resolve attached properties through the visitor instead.","triggerScenarios":"<Binding Path=\"(WrongType.NonExistentProperty)\"/>, a typo in the attached property name, or a property whose owning type was trimmed away so it is no longer registered.","commonSituations":"Misspelled owner type or property name; wrong xmlns prefix; attached property declared in an assembly that is not referenced; IL trimming/AOT removing the static field initializer that registers the AvaloniaProperty.","solutions":["Verify the owner type and property name spelling against AvaloniaPropertyRegistry registrations.","Ensure the declaring assembly is referenced and the AvaloniaProperty is registered (static field initializer preserved).","For trimming, root the registration with DynamicDependency / preserve initializers."],"exampleFix":"<!-- before -->\n<Binding Path=\"(Gird.Row)\"/>\n<!-- after -->\n<Binding Path=\"(Grid.Row)\"/>","handlingStrategy":"validation","validationCode":"// Before using an attached property name, confirm it is registered:\nstatic bool IsAttachedPropertyRegistered(Type ownerType, string name) =>\n    AvaloniaPropertyRegistry.Instance.FindRegistered(ownerType, name) is not null;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check attached property owner type and name against the registry before binding.","Ensure the owning assembly is referenced and its AvaloniaProperty initializer is preserved.","Under trimming, root property registrations so they are not removed."],"tags":["binding","reflection-binding","attached-property","xaml","trimming"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}