unoplatform/uno · error · XamlGenerationException
The property '{member.Member.Name}' of type '{propertyType}'
Error message
The property '{member.Member.Name}' of type '{propertyType}' does not support adding multiple objects What it means
Companion to 310 in the same branch: thrown when a property is single-valued (not a collection, no Add support) and the XAML provides more than one object inside it. The property type cannot accept multiple objects, so generation aborts at line 3461. This is the explicit-property-element version of the 'multiple children on a scalar' problem (cf. 305 which is the implicit-content version).
Source
Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs:3461
}
foreach (var inner in member.Objects)
{
writer.AppendIndented($"{localCollectionName}.Add(");
BuildChild(writer, member, inner);
writer.AppendLineIndented(");");
}
}
else if (member.Objects.Count == 1)
{
var childType = GetType(member.Objects[0].Type).GetFullyQualifiedTypeExcludingGlobal();
throw new XamlGenerationException($"Cannot assign child of type '{childType}' to property of type '{propertyType.GetFullyQualifiedTypeExcludingGlobal()}'", member.Objects[0]);
}
else
{
throw new XamlGenerationException($"The property '{member.Member.Name}' of type '{propertyType}' does not support adding multiple objects", member);
}
}
else
{
// GenerateWarning(writer, $"Unknown type {objectDefinition.Type} for property {member.Member.DeclaringType}");
}
}
else
{
var isMemberInsideResourceDictionary = IsMemberInsideResourceDictionary(objectDefinition);
var value = member.Value?.ToString();
if (
member.Member.Name == "Name"
&& member.Member.PreferredXamlNamespace == XamlConstants.XamlXmlNamespace
&& !isMemberInsideResourceDictionary.isInside
)
{View on GitHub (pinned to 0418340488)
Solutions
- Reduce to a single object inside the property-element tag.
- If multiple values are needed, confirm the property is collection-typed; if not, choose the correct collection property or wrap appropriately.
- Move extra objects to a sibling property-element that accepts them.
Example fix
<!-- before -->
<Button>
<Button.Content>
<TextBlock Text="A"/>
<TextBlock Text="B"/>
</Button.Content>
</Button>
<!-- after -->
<Button>
<Button.Content>
<StackPanel>
<TextBlock Text="A"/>
<TextBlock Text="B"/>
</StackPanel>
</Button.Content>
</Button> Defensive patterns
Strategy: validation
Validate before calling
# Structural lint: property-element tags with >1 element child where the property is scalar
Get-ChildItem -Recurse -Filter *.xaml | ForEach-Object {
$x = [xml](Get-Content $_.FullName)
$x.SelectNodes('//*[contains(local-name(),".")]') | ForEach-Object {
$kids = $_.ChildNodes | Where-Object { $_.NodeType -eq 'Element' }
if ($kids.Count -gt 1) { Write-Warning "$($_.LocalName) property-element has $($kids.Count) children" }
}
} Prevention
- Treat scalar properties as accepting exactly one value.
- If you need many items, confirm the property is a collection; otherwise wrap in a container.
When it happens
Trigger: Writing <MyControl.Title><x/><y/></MyControl.Title> where Title is a string/object (single); nesting two or more elements inside any property-element whose property is not a collection.
Common situations: Assuming a property is a collection when it is scalar; copy-pasting multiple setters into a single Value; porting XAML where a property's multiplicity differs.
Related errors
- Unable to implicitly initialize collection for '{contentProp
- Cannot assign child of type '{childType}' to property of typ
- instance
- item
- Non-collection type '{0}' does not support this operation
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/dba45e1fbf92c002.
Report an issue: GitHub.