diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 1620cd9a1926..fc7a79979af1 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -2771,9 +2771,16 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj if (HasMarkupExtension(member)) { - TryValidateContentPresenterBinding(writer, objectDefinition, member); + if (!IsXLoadMember(member)) + { + TryValidateContentPresenterBinding(writer, objectDefinition, member); - BuildComplexPropertyValue(writer, member, closureName + ".", closureName); + BuildComplexPropertyValue(writer, member, closureName + ".", closureName); + } + else + { + writer.AppendLineInvariant($"/* Skipping x:Load attribute already applied to ElementStub */"); + } } else if (HasCustomMarkupExtension(member)) { @@ -2941,8 +2948,7 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj { writer.AppendLineInvariant("// DeferLoadStrategy {0}", member.Value); } - else if (member.Member.Name == "Load" - && member.Member.PreferredXamlNamespace == XamlConstants.XamlXmlNamespace) + else if (IsXLoadMember(member)) { writer.AppendLineInvariant("// Load {0}", member.Value); } @@ -3125,6 +3131,10 @@ void BuildCustomMarkupExtensionPropertyValue(IIndentedStringBuilder writer, Xaml } } + private bool IsXLoadMember(XamlMemberDefinition member) => + member.Member.Name == "Load" + && member.Member.PreferredXamlNamespace == XamlConstants.XamlXmlNamespace; + private void GenerateInlineEvent(string? closureName, IIndentedStringBuilder writer, XamlMemberDefinition member, IEventSymbol eventSymbol) { // If a binding is inside a DataTemplate, the binding root in the case of an x:Bind is @@ -5317,14 +5327,6 @@ private IEnumerable EnumerateSubElements(IEnumerable