AvaloniaUI/Avalonia · error · ArgumentException
Property '{property.Name} not registered on '{o.GetType()}
Error message
Property '{property.Name} not registered on '{o.GetType()} What it means
Thrown by AvaloniaPropertyRegistry.GetRegisteredDirectUntyped when FindRegisteredDirectUntyped returns null, meaning the supplied direct property is not registered on the target object's type (or any of its base types). The registry walks the type hierarchy for direct properties and this one was not found.
Source
Thrown at src/Avalonia.Base/AvaloniaPropertyRegistry.cs:266
/// <summary>
/// Gets a direct property as registered on an object.
/// </summary>
/// <param name="o">The object.</param>
/// <param name="property">The direct property.</param>
/// <returns>
/// The registered.
/// </returns>
public DirectPropertyBase<T> GetRegisteredDirect<T>(
AvaloniaObject o,
DirectPropertyBase<T> property)
{
return (DirectPropertyBase<T>)GetRegisteredDirectUntyped(o, property);
}
internal AvaloniaProperty GetRegisteredDirectUntyped(AvaloniaObject o, AvaloniaProperty property)
{
return FindRegisteredDirectUntyped(o, property) ??
throw new ArgumentException($"Property '{property.Name} not registered on '{o.GetType()}");
}
/// <summary>
/// Finds a registered property on a type by name.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="name">The property name.</param>
/// <returns>
/// The registered property or null if no matching property found.
/// </returns>
/// <exception cref="InvalidOperationException">
/// The property name contains a '.'.
/// </exception>
public AvaloniaProperty? FindRegistered(Type type, string name)
{
_ = type ?? throw new ArgumentNullException(nameof(type));
_ = name ?? throw new ArgumentNullException(nameof(name));
View on GitHub (pinned to 11c5427268)
Solutions
- Verify the direct property is registered on the exact type of the object via AvaloniaPropertyRegistry.Instance.IsRegistered(o, property) before calling GetRegisteredDirect.
- Ensure the type that declares the direct property (via AvaloniaProperty.RegisterDirect) is the same type or a base of o.GetType().
- Call the type-safe FindRegisteredDirect<T> variant which returns null instead of throwing, and handle the null case.
- Confirm no UnregisterByModule call removed the property for the relevant type.
Example fix
// before
var reg = registry.GetRegisteredDirect(control, MyControl.FooProperty);
// after
if (registry.IsRegistered(control, MyControl.FooProperty)) {
var reg = registry.GetRegisteredDirect(control, MyControl.FooProperty);
} Defensive patterns
Strategy: validation
Validate before calling
if (!AvaloniaPropertyRegistry.Instance.IsRegistered(o, property)) { /* not registered; handle gracefully */ } Prevention
- Call IsRegistered(o, property) before GetRegisteredDirect.
- Prefer the type-safe FindRegisteredDirect<T> that returns null instead of throwing.
- Confirm the declaring type is in the object's hierarchy.
When it happens
Trigger: Passing a DirectPropertyBase<T> to GetRegisteredDirect(o, property) where property is not registered on o's type; using a direct property defined on a different control type; accessing a direct property before its owning type's static constructor has registered it.
Common situations: Mixing up direct property definitions between unrelated control types; referencing a base-class direct property on a derived instance that re-registered it differently; type-reloading scenarios where UnregisterByModule removed the property.
Related errors
- Cannot register a non-attached property as attached.
- 'name' may not contain periods.
- The metadata is read-only.
- Attached properties not supported.
- Cannot set direct property '{Property}' in '{instance.Source
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/cda2cb2e7a9eefd7.
Report an issue: GitHub.