microsoft / microsoft-ui-xaml

WinUI: a modern UI framework with a rich set of controls and styles to build dynamic and high-performing Windows applications.
MIT License
6.37k stars 682 forks source link

Cannot {x:Bind} to property of named non-control in C++/WinRT #10130

Open HO-COOH opened 2 weeks ago

HO-COOH commented 2 weeks ago

Describe the bug

Related to #2721, that issue is fixed, we can now bind to a property of a named control, but binding to named non-control is still causing compile error (you still need to redeclare it in the idl).

Steps to reproduce the bug

  1. Create a new C++ winui3 project
  2. In MainWindow.xaml, use this xaml

    <StackPanel Orientation="Vertical" Spacing="10">
        <Slider
            x:Name="RotationSlider"
            Width="500"
            Value="{x:Bind Rotation.Angle, Mode=TwoWay}" />
    
        <Border
            Width="500"
            Height="500"
            Background="Red">
            <Border.RenderTransform>
                <RotateTransform x:Name="Rotation" />
            </Border.RenderTransform>
        </Border>
    </StackPanel>

Expected behavior

No response

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002

Windows version

No response

Additional context

Repro

karkarl commented 2 weeks ago

Your example here is not expected to work, as RotateTransform is not a dependency object. Hence, the TwoWay binding will not work.

HO-COOH commented 2 weeks ago

Your example here is not expected to work, as RotateTransform is not a dependency object. Hence, the TwoWay binding will not work.

@karkarl I might be drunk then. Image

Also, the exact code works in C# project.

karkarl commented 2 weeks ago

@chrisglein can you take a look at this?