dotnet/maui · error · XamlParseException

The PropertyName of {type.Name}.{name} is not {propertyName}

Error message

The PropertyName of {type.Name}.{name} is not {propertyName}

What it means

XamlParseException raised when the BindableProperty field was found but its registered PropertyName does not match the propertyName the XAML used. MAUI cross-checks to catch renamed-but-not-updated XAML; the only exception is when the field is marked [Obsolete] (the converter then tolerates the old name). Otherwise the field and the XAML name must agree.

Source

Thrown at src/Controls/src/Core/BindablePropertyConverter.cs:106

			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);

		[UnconditionalSuppressMessage("TrimAnalysis", "IL2070:UnrecognizedReflectionPattern",
			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 FieldInfo GetPropertyField(Type type, string fieldName)

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Align the XAML attribute with the registered PropertyName (what was passed to Create).
  2. Or mark the field [Obsolete] and keep the old XAML name as an alias.
  3. Rebuild after fixing so XAMLC re-validates.

Example fix

// before: field named TitleProperty but registered as 'Heading'
public static readonly BindableProperty TitleProperty =
    BindableProperty.Create(nameof(Heading), typeof(string), typeof(V), default);

// after: align names
public static readonly BindableProperty TitleProperty =
    BindableProperty.Create(nameof(Title), typeof(string), typeof(V), default);
Defensive patterns

Strategy: validation

Validate before calling

// At authoring time, verify the registered PropertyName matches the field name suffix:
var bp = (BindableProperty)fi.GetValue(null);
if (bp.PropertyName != expectedName && !fi.IsDefined(typeof(ObsoleteAttribute)))
    /* flag mismatch */

Prevention

When it happens

Trigger: A field named FooProperty whose BindableProperty.Create registered PropertyName="Bar"; a refactor that renamed the C# property but not the registered PropertyName; XAML referencing the old name while the registered name changed and the field is not [Obsolete].

Common situations: Splitting a rename across two commits; third-party control that registered a different PropertyName than the field name suggests; generated BindableProperties where the generator and the registration disagree.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/a17ce5dadaa84365. Report an issue: GitHub.