AvaloniaUI/Avalonia · error · ExpressionParseException
Attached Property name expected after '.'.
Error message
Attached Property name expected after '.'.
What it means
Thrown by ParseAttachedProperty after the parser successfully consumed the '.' separator following the type name in '(Owner.', but ParseIdentifier returned an empty span — meaning no valid identifier characters follow the dot. In Avalonia's binding grammar the '.' in an attached property must be immediately followed by a property name; whitespace, end-of-string, or non-identifier characters after the dot all trigger this error.
Source
Thrown at src/Avalonia.Base/Data/Core/Parsers/BindingExpressionGrammar.cs:238
{
var (ns, owner) = ParseTypeName(ref r);
if(!r.End && r.TakeIf(')'))
{
nodes.Add(new TypeCastNode() { Namespace = ns, TypeName = owner });
return State.AfterMember;
}
if (r.End || !r.TakeIf('.'))
{
throw new ExpressionParseException(r.Position, "Invalid attached property name.");
}
var name = r.ParseIdentifier();
if (name.Length == 0)
{
throw new ExpressionParseException(r.Position, "Attached Property name expected after '.'.");
}
if (r.End || !r.TakeIf(')'))
{
throw new ExpressionParseException(r.Position, "Expected ')'.");
}
nodes.Add(new AttachedPropertyNameNode
{
AcceptsNull = acceptsNull,
Namespace = ns,
TypeName = owner,
PropertyName = name.ToString()
});
return State.AfterMember;
}
private static State ParseIndexer(ref CharacterReader r, List<INode> nodes)View on GitHub (pinned to 11c5427268)
Solutions
- Add a valid property name immediately after the '.' in the attached-property path: '(Grid.Row)' not '(Grid.)'.
- Ensure there is no whitespace between the '.' and the property name.
- If the property name contains special characters, use the CLR property name as registered, not the XAML attribute name.
Example fix
<!-- before: no property name after '.' -->
<TextBox Text="{Binding (Grid.)}" />
<!-- after: property name added -->
<TextBox Text="{Binding (Grid.Row)}" /> Defensive patterns
Strategy: validation
Validate before calling
// Check that every '.' inside parentheses is followed by an identifier
static void ValidateAttachedPropertyName(string path)
{
int depth = 0;
for (int i = 0; i < path.Length; i++)
{
if (path[i] == '(') depth++;
else if (path[i] == ')') depth--;
else if (depth > 0 && path[i] == '.')
{
if (i + 1 >= path.Length || !(char.IsLetter(path[i + 1]) || path[i + 1] == '_'))
throw new ArgumentException(
$"'.' at position {i} is not followed by a valid property name");
}
}
} Try / catch
try
{
var binding = new Binding(path);
}
catch (ExpressionParseException ex) when (ex.Message.Contains("Attached Property name expected"))
{
logger.LogError($"Missing property name after '.' at column {ex.Column}");
} Prevention
- Always complete the '(Type.PropertyName)' pattern in one typing pass to avoid leaving a dangling dot.
- If using auto-complete, verify the full expression is inserted, not just the type name and dot.
- Test attached-property binding paths with small unit tests against the parser.
When it happens
Trigger: Writing '(Grid.' at end of string or '(Grid. ' with whitespace or a non-identifier character after the dot. ParseIdentifier only accepts characters valid in a C# identifier, so '(Grid.123)' or '(Grid.;)' would also reach this point after the dot is consumed.
Common situations: Typo where the property name was truncated after the dot; auto-complete inserted the dot but not the name; attempting to use a numeric or symbolic property name that is not a valid identifier in the binding mini-language.
Related errors
- Invalid attached property name.
- Expected ')'.
- Unexpected end of expression.
- Indexer may not be empty.
- Element name expected after '#'.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/00f1fcf40c8c222d.
Report an issue: GitHub.