Skip to content

Binding codes are not emitted when the type {Control}Extension exists in the same namespace #21992

Closed

Description

@davidxuang

Current behavior 🐛

Reported in davidxuang/FluentIcons#37. Data binding on custom dependency properties does not work on Uno.WinUI while it works as expected on WinAppSDK. This behaviour consist across multiple Uno 6.x versions. We tried to compare our code base to Uno controls like https://github.com/unoplatform/uno/blob/master/src/Uno.UI/UI/Xaml/Controls/Icons/FontIcon.cs but didn't find noticable differences.

Expected behavior 🎯

See reproduction

How to reproduce it (as minimally and precisely as possible) 🔬

A demo is uploaded to https://github.com/davidxuang/FluentIcons/tree/uno-binding.

<Page
    x:Class="UnoApp1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:local="using:UnoApp1"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <ScrollViewer IsTabStop="True">
        <Grid>
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                <TextBlock
                    HorizontalAlignment="Center"
                    AutomationProperties.AutomationId="HelloTextBlock"
                    Text="{x:Bind Text}" />
                <ic:FluentIcon Icon="Add" />
                <ic:FluentIcon Icon="{x:Bind Path=Icon}" />
            </StackPanel>
        </Grid>
    </ScrollViewer>
</Page>
using FluentIcons.Common;

namespace UnoApp1;

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
    }

    public string Text => Icon.ToString();
    public Icon Icon => Icon.Add;
}

With WinAppSDK unpackaged:

Image

With Uno Desktop:

Image

Workaround 🛠️

No response

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

Desktop (Windows)

Uno.Sdk version (and other relevant versions) 📦

6.4.31

IDE version 🧑‍💻

Visual Studio 2026 18.0.2

Anything else we need to know? 💬

No response

Activity

  1. added
    triage/untriaged
    difficulty/tbd
    on Nov 28, 2025
  2. added theissue type on Nov 28, 2025
  3. davidxuang commented on Nov 30, 2025

    @davidxuang
    Author

    I have identified the source of the bug. This is something similar to #11. Uno XAML source generator tried to test if FluentIcon is a markup extension, but FluentIconExtension in the same namespace got tested instead.

    return FindMarkupExtensionType(baseTypeString + "Extension") ?? FindMarkupExtensionType(baseTypeString);

    Which prevents the emission of binding code by BuildComplexPropertyValue here:

    if (HasMarkupExtension(member))
    {
    if (!IsXLoadMember(member))
    {
    TryAnnotateWithGeneratorSource(writer);
    BuildComplexPropertyValue(writer, member, writer.AppliedParameterName + ".", writer.AppliedParameterName, componentDefinition: componentDefinition);
    }
    else
    {
    writer.AppendLineIndented($"/* Skipping x:Load attribute already applied to ElementStub */");
    }
    }

    This behaviour is different from WinUI and might needs to be fixed.

    This is the calling stack for the generator:

    >	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.GetMarkupExtensionType(Uno.UI.SourceGenerators.XamlGenerator.XamlRedirection.XamlType xamlType) line 2032	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.IsCustomMarkupExtensionType(Uno.UI.SourceGenerators.XamlGenerator.XamlRedirection.XamlType xamlType) line 2042	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.HasMarkupExtension(Uno.UI.SourceGenerators.XamlGenerator.XamlMemberDefinition valueNode) line 1905	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildExtendedProperties(Uno.Extensions.IIndentedStringBuilder outerwriter, Uno.UI.SourceGenerators.XamlGenerator.XamlObjectDefinition objectDefinition, bool useGenericApply) line 3117	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildChild(Uno.Extensions.IIndentedStringBuilder writer, Uno.UI.SourceGenerators.XamlGenerator.XamlMemberDefinition owner, Uno.UI.SourceGenerators.XamlGenerator.XamlObjectDefinition xamlObjectDefinition, string outerClosure) line 6129	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildProperties(Uno.Extensions.IIndentedStringBuilder writer, Uno.UI.SourceGenerators.XamlGenerator.XamlObjectDefinition topLevelControl, bool isInline, string closureName, bool useBase) line 2348	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildChild.AnonymousMethod__4() line 6097	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.Safely(System.Action action, string name, int line) line 82	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildChild(Uno.Extensions.IIndentedStringBuilder writer, Uno.UI.SourceGenerators.XamlGenerator.XamlMemberDefinition owner, Uno.UI.SourceGenerators.XamlGenerator.XamlObjectDefinition xamlObjectDefinition, string outerClosure) line 6097	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildProperties(Uno.Extensions.IIndentedStringBuilder writer, Uno.UI.SourceGenerators.XamlGenerator.XamlObjectDefinition topLevelControl, bool isInline, string closureName, bool useBase) line 2433	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildGenericControlInitializerBody.AnonymousMethod__0() line 751	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.Safely(System.Action action, string name, int line) line 82	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildGenericControlInitializerBody(Uno.Extensions.IIndentedStringBuilder writer, Uno.UI.SourceGenerators.XamlGenerator.XamlObjectDefinition topLevelControl) line 751	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildInitializeComponent.AnonymousMethod__1() line 447	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.Safely(System.Action action, string name, int line) line 82	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildInitializeComponent(Uno.Extensions.IndentedStringBuilder writer, Uno.UI.SourceGenerators.XamlGenerator.XamlObjectDefinition topLevelControl, Microsoft.CodeAnalysis.INamedTypeSymbol controlBaseType) line 447	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.GenerateFile() line 367	C#
     	Uno.UI.SourceGenerators.dll!Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration.Generate.AnonymousMethod__2(Uno.UI.SourceGenerators.XamlGenerator.XamlFileDefinition file) line 465	C#
    
  4. changed the title [-]`x:Bind` does not work on custom controls[/-] [+]Binding codes are not emitted when the type `{Control}Extension` exists in the same namespace[/+] on Nov 30, 2025
  5. added
    stale
    area/code-generation
    area/xaml-reader
    kind/papercut
    and removed
    triage/untriaged
    difficulty/tbd
    stale
    on Dec 15, 2025
  6. github-actions commented on May 19, 2026

    @github-actions
    Contributor

    This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.

  7. added
    stale
    on May 19, 2026
  8. removed
    stale
    on May 19, 2026
  9. added a commit that references this issue on Jun 23, 2026
    6141e1f
  10. khaskoul commented on Aug 3, 2026

    @khaskoul
    Environment Value
    Uno SDK 6.7.0-dev.160
    TFMs built net10.0-desktop, net10.0-windows10.0.26100, net10.0-browserwasm (all 0 warnings / 0 errors)
    ProbeIcon — no ProbeIconExtension (baseline)
      [PASS] stock TextBlock.Text {x:Bind}
             Text="bound", expected "bound"
      [PASS] custom DP literal setter
             Kind=Edit Label="literal", expected Edit/"literal"
      [PASS] custom DP {x:Bind}
             Kind=Delete Label="bound", expected Delete/"bound"
      [PASS] custom DP {Binding}
             Kind=Delete Label="bound", expected Delete/"bound"
    ShadowedIcon — ShadowedIconExtension : MarkupExtension
      [PASS] stock TextBlock.Text {x:Bind}
             Text="bound", expected "bound"
      [PASS] custom DP literal setter
             Kind=Edit Label="literal", expected Edit/"literal"
      [PASS] custom DP {x:Bind}
             Kind=Delete Label="bound", expected Delete/"bound"
      [PASS] custom DP {Binding}
             Kind=Delete Label="bound", expected Delete/"bound"
    PlainIcon — PlainIconExtension (plain class)
      [PASS] stock TextBlock.Text {x:Bind}
             Text="bound", expected "bound"
      [PASS] custom DP literal setter
             Kind=Edit Label="literal", expected Edit/"literal"
      [PASS] custom DP {x:Bind}
             Kind=Delete Label="bound", expected Delete/"bound"
      [PASS] custom DP {Binding}
             Kind=Delete Label="bound", expected Delete/"bound"
    FluentProbeIcon — FluentProbeIconExtension + Icon name collision
      [PASS] stock TextBlock.Text {x:Bind}
             Text="bound", expected "bound"
      [PASS] custom DP literal setter
             Kind=Edit Label="literal", expected Edit/"literal"
      [PASS] custom DP {x:Bind}
             Kind=Delete Label="bound", expected Delete/"bound"
      [PASS] custom DP {Binding}
             Kind=Delete Label="bound", expected Delete/"bound"
    
    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/code-generationarea/xaml-readerkind/papercut

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions