unoplatform/uno · error · XamlGenerationException
The type '{topLevelControl.Type.Name}' does not support mult
Error message
The type '{topLevelControl.Type.Name}' does not support multiple children What it means
Thrown in BuildProperties when a Border element has more than one object in its implicit content. Border exposes a single Child property (not a Children collection), so only one child element is permitted. The check at line 2489 fires after the generator confirms the type is a Border and finds multiple objects inside it.
Source
Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs:2489
}
}
}
else if (IsNativePage(topLevelControlSymbol))
{
if (implicitContentChild.Objects.Count > 0)
{
writer.AppendLineInvariantIndented("{0}Content = ", setterPrefix);
BuildChild(writer, implicitContentChild, implicitContentChild.Objects.First());
}
}
else if (IsBorder(topLevelControlSymbol))
{
if (implicitContentChild.Objects.Count > 0)
{
if (implicitContentChild.Objects.Count > 1)
{
throw new XamlGenerationException($"The type '{topLevelControl.Type.Name}' does not support multiple children", implicitContentChild.Objects[1]);
}
writer.AppendLineInvariantIndented("{0}Child = ", setterPrefix);
var implicitContent = implicitContentChild.Objects.First();
using (TryAdaptNative(writer, implicitContent, Generation.UIElementSymbol.Value))
{
BuildChild(writer, implicitContentChild, implicitContent);
}
}
}
else if (IsType(topLevelControlSymbol, Generation.SolidColorBrushSymbol.Value))
{
if (implicitContentChild.Value is string content && !content.IsNullOrWhiteSpace())
{
writer.AppendLineIndented($"{setterPrefix}Color = {BuildColor(content)}");
}
}View on GitHub (pinned to 0418340488)
Solutions
- Wrap the multiple children in a single container such as <Grid> or <StackPanel> inside the Border.
- Remove all but one child element if only one is intended.
- If you need a border around multiple items, use Border > Grid > (children).
Example fix
<!-- before -->
<Border BorderBrush="Red" BorderThickness="1">
<TextBlock Text="A"/>
<TextBlock Text="B"/>
</Border>
<!-- after -->
<Border BorderBrush="Red" BorderThickness="1">
<StackPanel>
<TextBlock Text="A"/>
<TextBlock Text="B"/>
</StackPanel>
</Border> Defensive patterns
Strategy: validation
Validate before calling
# Heuristic: flag <Border> elements with more than one direct child element
# (parse with [xml] and count element children of Border)
Get-ChildItem -Recurse -Filter *.xaml | ForEach-Object {
$x = [xml](Get-Content $_.FullName)
$x.SelectNodes('//*[local-name()="Border"]') | ForEach-Object {
$kids = $_.ChildNodes | Where-Object { $_.NodeType -eq 'Element' }
if ($kids.Count -gt 1) { Write-Warning "$($_.Name) Border has $($kids.Count) children" }
}
} Prevention
- Remember Border has a single Child, not Children — wrap multiple items in a Grid/StackPanel.
- When converting a Grid to a Border, immediately wrap existing children in a panel.
When it happens
Trigger: Writing two or more child elements directly inside a <Border> element (e.g. <Border><TextBlock/><Button/></Border>); placing content plus another element without an explicit property wrapper.
Common situations: Expecting Border to behave like a Panel (Grid/StackPanel) that accepts many children; converting a Grid to a Border and forgetting to wrap the children; copy-paste adding a second element inside an existing Border.
Related errors
- Unable to implicitly initialize collection for '{contentProp
- '{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
- There is already a resource with name '{name}'
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/1a55314d24f93bff.
Report an issue: GitHub.