unoplatform/uno · error · XamlGenerationException
x:Bind event path cannot be empty
Error message
x:Bind event path cannot be empty
What it means
Thrown in the x:Bind event-handling code path when XBindExpressionParser.RestoreSinglePath returns null for the bind's first member value — i.e. the x:Bind expression on an event has no path/method name at all (e.g. Click="{x:Bind}" or an empty path). An event binding must name a handler method to invoke.
Source
Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs:3812
.DelegateInvokeMethod
?.Parameters
.Select(p => p.Name)
.ToArray();
if (member.Objects.FirstOrDefault() is XamlObjectDefinition bind && bind.Type.Name == "Bind")
{
if (componentDefinition is null)
{
// 500 - Internal XAML Code gen error
throw new XamlGenerationException("The component definition cannot be null", bind);
}
CurrentScope.XBindExpressions.Add(bind);
var path = XBindExpressionParser.RestoreSinglePath(bind.Members.First().Value?.ToString());
if (path is null)
{
throw new XamlGenerationException("x:Bind event path cannot be empty", bind);
}
INamedTypeSymbol GetTargetType()
{
if (template.isInside)
{
var dataTypeObject = FindMember(template.xamlObject!, "DataType", XamlConstants.XamlXmlNamespace);
if (dataTypeObject?.Value == null)
{
// Check if this is a static method binding (path starts with a namespace prefix like "local:Type")
// Static bindings don't require x:DataType because they don't access the DataContext
var pathParts = path.Split('.');
var isStaticBinding = pathParts.FirstOrDefault()?.Contains(":") ?? false;
if (isStaticBinding)
{
// Extract the type from the static path (e.g., "local:StaticHandler" from "local:StaticHandler.OnClick")
return GetType(RewriteNamespaces(pathParts[0]));View on GitHub (pinned to 0418340488)
Solutions
- Provide a handler method path in the x:Bind, e.g. Click="{x:Bind OnClick}".
- Ensure the named method exists on the bind target (the page or the x:DataType).
- If binding a property (not an event), use the normal {x:Bind PropertyPath} form on a non-event attribute.
Example fix
<!-- before -->
<Button Click="{x:Bind}"/>
<!-- after -->
<Button Click="{x:Bind OnClick}"/> Defensive patterns
Strategy: validation
Validate before calling
# Flag empty x:Bind on event attributes
Get-ChildItem -Recurse -Filter *.xaml | ForEach-Object {
Select-String -Path $_.FullName -Pattern '\{x:Bind\s*\}' |
ForEach-Object { Write-Warning "$($_.Filename):$($_.LineNumber): empty x:Bind path" }
} Prevention
- Event x:Bind must name a handler method, e.g. {x:Bind OnClick}.
- Distinguish event binding (method) from property binding (path).
When it happens
Trigger: Writing an event attribute as {x:Bind} with no member path; a malformed x:Bind whose path parses to null; an empty x:Bind expression string.
Common situations: Authoring a binding in the editor and not finishing the path; refactor that empties a binding expression; misunderstanding that event x:Bind requires a method name, not a property path.
Related errors
- Unable to find x:DataType in enclosing DataTemplate for x:Bi
- Unable to find the type '{_xClassName?.Namespace}.{_xClassNa
- '{memberName}' is not defined on '{xamlObjectDefinition.Type
- Unable to find class name for toplevel control
- Unable to find x:Class on the top level element
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/94145d470b3cbfe8.
Report an issue: GitHub.