AvaloniaUI/Avalonia · error · InvalidOperationException
Cannot find property {type}.{attached.PropertyName}.
Error message
Cannot find property {type}.{attached.PropertyName}. What it means
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.
Source
Thrown at src/Avalonia.Base/Data/Core/Parsers/ExpressionNodeFactory.cs:117
new VisualAncestorElementNode(source.AncestorType, source.AncestorLevel - 1),
_ => throw new NotSupportedException("Unsupported RelativeSource mode.")
};
}
public static ExpressionNode CreateDataContext(AvaloniaProperty? targetProperty)
{
return targetProperty == StyledElement.DataContextProperty ?
new ParentDataContextNode() :
new DataContextNode();
}
private static AvaloniaPropertyAccessorNode AttachedPropertyNode(
Func<string?, string, Type?>? typeResolver,
BindingExpressionGrammar.AttachedPropertyNameNode attached)
{
var type = LookupType(typeResolver, attached.Namespace, attached.TypeName);
var property = AvaloniaPropertyRegistry.Instance.FindRegistered(type, attached.PropertyName) ??
throw new InvalidOperationException($"Cannot find property {type}.{attached.PropertyName}.");
return new AvaloniaPropertyAccessorNode(property);
}
private static LogicalAncestorElementNode LogicalAncestorNode(
Func<string?, string, Type?>? typeResolver,
BindingExpressionGrammar.AncestorNode ancestor)
{
Type? type = null;
if (!string.IsNullOrEmpty(ancestor.TypeName))
{
type = LookupType(typeResolver, ancestor.Namespace, ancestor.TypeName);
}
return new LogicalAncestorElementNode(type, ancestor.Level);
}
private static Type LookupType(View on GitHub (pinned to 11c5427268)
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.
Example fix
<!-- before --> <Binding Path="(Gird.Row)"/> <!-- after --> <Binding Path="(Grid.Row)"/>
Defensive patterns
Strategy: validation
Validate before calling
// Before using an attached property name, confirm it is registered:
static bool IsAttachedPropertyRegistered(Type ownerType, string name) =>
AvaloniaPropertyRegistry.Instance.FindRegistered(ownerType, name) is not null; Prevention
- 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.
When it happens
Trigger: <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.
Common situations: 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.
Related errors
- Unable to resolve type '{@namespace}:{name}'.
- Invalid attached property name.
- Attached Property name expected after '.'.
- Expected ')'.
- Unable to resolve unnamed type from namespace '{@namespace}'
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/bf17ee49822781ad.
Report an issue: GitHub.