dotnet/maui · error · XamlParseException

Can't resolve {value}. Syntax is [[prefix:]Type.]PropertyNam

Error message

Can't resolve {value}. Syntax is [[prefix:]Type.]PropertyName.

What it means

XamlParseException raised when the value split on '.' does not have exactly 1 or 2 segments. The converter only understands bare PropertyName or Type.PropertyName; anything else (zero segments, three or more, or a leading/trailing dot) is syntactically invalid and is rejected with a syntax hint.

Source

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

					type = (parentValuesProvider.TargetObject as Trigger).TargetType;
				else if (parentValuesProvider.TargetObject is PropertyCondition && parent is TriggerBase)
					type = (parent as TriggerBase).TargetType;

				if (type == null)
					throw new XamlParseException($"Can't resolve {parts[0]}", lineinfo);

				return ConvertFrom(type, parts[0], lineinfo);
			}
			if (parts.Length == 2)
			{
				if (!typeResolver.TryResolve(parts[0], out type))
				{
					string msg = string.Format("Can't resolve {0}", parts[0]);
					throw new XamlParseException(msg, lineinfo);
				}
				return ConvertFrom(type, parts[1], lineinfo);
			}
			throw new XamlParseException($"Can't resolve {value}. Syntax is [[prefix:]Type.]PropertyName.", lineinfo);
		}

		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
		{
			var strValue = value?.ToString();

			if (string.IsNullOrWhiteSpace(strValue))
				return null;
			if (strValue.IndexOf(":", StringComparison.Ordinal) != -1)
			{
				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;

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Use the supported syntax: either PropertyName or Type.PropertyName.
  2. For attached properties, use the form Type.PropertyName (e.g. Grid.Column).
  3. Remove stray dots or extra segments from the attribute.

Example fix

<!-- before -->
<Setter Property="A.B.C" Value="1" />

<!-- after -->
<Setter Property="Grid.Column" Value="1" />
Defensive patterns

Strategy: validation

Validate before calling

// Validate the property token has exactly one or two dot-separated segments before use.
static bool IsValidPropertySyntax(string s)
{
    if (string.IsNullOrWhiteSpace(s)) return false;
    var n = s.Split('.').Length;
    return n == 1 || n == 2;
}

Type guard

static bool IsValidPropertySyntax(string s) =>
    !string.IsNullOrWhiteSpace(s) && (s.Split('.').Length is 1 or 2);

Prevention

When it happens

Trigger: Property="A.B.C" (three segments); Property=".Foo" or "Foo." (leading/trailing dot); Property="" or whitespace that survived the earlier IsNullOrWhiteSpace check; a value that accidentally contains a dot inside a namespace token.

Common situations: Typos; copy-paste from a different binding syntax; trying to write an attached-property path with extra dots; XAML tools that emit malformed attributes.

Related errors


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