{"record":{"id":"94145d470b3cbfe8","repo":"unoplatform/uno","slug":"x-bind-event-path-cannot-be-empty","errorCode":null,"errorMessage":"x:Bind event path cannot be empty","messagePattern":"x:Bind event path cannot be empty","errorType":"exception","errorClass":"XamlGenerationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs","lineNumber":3812,"sourceCode":"\t\t\t\t.DelegateInvokeMethod\n\t\t\t\t?.Parameters\n\t\t\t\t.Select(p => p.Name)\n\t\t\t\t.ToArray();\n\n\t\t\tif (member.Objects.FirstOrDefault() is XamlObjectDefinition bind && bind.Type.Name == \"Bind\")\n\t\t\t{\n\t\t\t\tif (componentDefinition is null)\n\t\t\t\t{\n\t\t\t\t\t// 500 - Internal XAML Code gen error\n\t\t\t\t\tthrow new XamlGenerationException(\"The component definition cannot be null\", bind);\n\t\t\t\t}\n\n\t\t\t\tCurrentScope.XBindExpressions.Add(bind);\n\n\t\t\t\tvar path = XBindExpressionParser.RestoreSinglePath(bind.Members.First().Value?.ToString());\n\t\t\t\tif (path is null)\n\t\t\t\t{\n\t\t\t\t\tthrow new XamlGenerationException(\"x:Bind event path cannot be empty\", bind);\n\t\t\t\t}\n\n\t\t\t\tINamedTypeSymbol GetTargetType()\n\t\t\t\t{\n\t\t\t\t\tif (template.isInside)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar dataTypeObject = FindMember(template.xamlObject!, \"DataType\", XamlConstants.XamlXmlNamespace);\n\t\t\t\t\t\tif (dataTypeObject?.Value == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Check if this is a static method binding (path starts with a namespace prefix like \"local:Type\")\n\t\t\t\t\t\t\t// Static bindings don't require x:DataType because they don't access the DataContext\n\t\t\t\t\t\t\tvar pathParts = path.Split('.');\n\t\t\t\t\t\t\tvar isStaticBinding = pathParts.FirstOrDefault()?.Contains(\":\") ?? false;\n\n\t\t\t\t\t\t\tif (isStaticBinding)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// Extract the type from the static path (e.g., \"local:StaticHandler\" from \"local:StaticHandler.OnClick\")\n\t\t\t\t\t\t\t\treturn GetType(RewriteNamespaces(pathParts[0]));","sourceCodeStart":3794,"sourceCodeEnd":3830,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs#L3794-L3830","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"<!-- before -->\n<Button Click=\"{x:Bind}\"/>\n\n<!-- after -->\n<Button Click=\"{x:Bind OnClick}\"/>","handlingStrategy":"validation","validationCode":"# Flag empty x:Bind on event attributes\nGet-ChildItem -Recurse -Filter *.xaml | ForEach-Object {\n  Select-String -Path $_.FullName -Pattern '\\{x:Bind\\s*\\}' |\n    ForEach-Object { Write-Warning \"$($_.Filename):$($_.LineNumber): empty x:Bind path\" }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Event x:Bind must name a handler method, e.g. {x:Bind OnClick}.","Distinguish event binding (method) from property binding (path)."],"tags":["xaml","x-bind","event-binding","build"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}