dotnet/maui · error · XamlParseException
Can't resolve {name} on {type.Name}
Error message
Can't resolve {name} on {type.Name} What it means
XamlParseException raised by ConvertFrom when, having resolved the owning Type and built the field name (propertyName + "Property"), GetPropertyField returns null or a field whose type is not BindableProperty. The named BindableProperty field simply does not exist on that type (public static, flattened up the hierarchy).
Source
Thrown at src/Controls/src/Core/BindablePropertyConverter.cs:102
Application.Current?.FindMauiContext()?.CreateLogger<BindablePropertyConverter>()?.LogWarning("Can't resolve properties with xml namespace prefix.");
return null;
}
string[] parts = strValue.Split('.');
if (parts.Length != 2)
{
Application.Current?.FindMauiContext()?.CreateLogger<BindablePropertyConverter>()?.LogWarning($"Can't resolve {value}. Accepted syntax is Type.PropertyName.");
return null;
}
Type type = GetControlType(parts[0]);
return ConvertFrom(type, parts[1], null);
}
BindableProperty ConvertFrom(Type type, string propertyName, IXmlLineInfo lineinfo)
{
var name = propertyName + "Property";
FieldInfo bpinfo = GetPropertyField(type, name);
if (bpinfo == null || bpinfo.FieldType != typeof(BindableProperty))
throw new XamlParseException($"Can't resolve {name} on {type.Name}", lineinfo);
var bp = bpinfo.GetValue(null) as BindableProperty;
var isObsolete = GetObsoleteAttribute(bpinfo) != null;
if (bp.PropertyName != propertyName && !isObsolete)
throw new XamlParseException($"The PropertyName of {type.Name}.{name} is not {propertyName}", lineinfo);
return bp;
}
[UnconditionalSuppressMessage("TrimAnalysis", "IL2045:AttributeRemoval",
Justification = "ObsoleteAttribute instances are removed by the trimmer in production builds.")]
static ObsoleteAttribute GetObsoleteAttribute(FieldInfo fieldInfo)
=> fieldInfo.GetCustomAttribute<ObsoleteAttribute>();
[UnconditionalSuppressMessage("TrimAnalysis", "IL2057:TypeGetType",
Justification = "The converter is only used when parsing XAML at runtime. The developer will receive a warning " +
"saying that parsing XAML at runtime may not work as expected when trimming.")]
static Type GetControlType(string typeName)
=> Type.GetType("Microsoft.Maui.Controls." + typeName);
View on GitHub (pinned to f377ff1c5e)
Solutions
- Verify the exact property name spelling against the control's API surface.
- If the property was renamed, update the XAML to the new name.
- Ensure the control version referenced actually declares that BindableProperty.
Example fix
<!-- before --> <Setter Property="local:MyCtrl.Titel" Value="x" /> <!-- after --> <Setter Property="local:MyCtrl.Title" Value="x" />
Defensive patterns
Strategy: validation
Validate before calling
// Cross-check at authoring time: the type must expose a static BindableProperty field
// named <PropertyName>Property.
var fi = ownerType.GetProperty($"{propName}Property", BindingFlags.Public | BindingFlags.Static);
if (fi?.FieldType != typeof(BindableProperty)) /* flag the typo */ Type guard
static bool PropertyExistsOnType(Type t, string propName) =>
t.GetField(propName + "Property", BindingFlags.Public | BindingFlags.Static)?.FieldType
== typeof(Microsoft.Maui.Controls.BindableProperty); Prevention
- Cross-reference XAML property names against the control's API docs.
- Rebuild XAMLC early to catch missing property fields.
When it happens
Trigger: Property="MyCtrl.Foo" when MyCtrl has no FooProperty field; misspelling the property name; referencing a property that was renamed or removed; the field exists but is not declared as BindableProperty.
Common situations: Typo in property name; renaming a BindableProperty without updating XAML; referencing a control version where the property did not yet exist.
Related errors
- Can't resolve {parts[0]}
- Can't resolve {0}
- Can't resolve {value}. Syntax is [[prefix:]Type.]PropertyNam
- The PropertyName of {type.Name}.{name} is not {propertyName}
- XC0040
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/39fc745c87e774c5.
Report an issue: GitHub.