Skip to content

ElementStyle with bindings initially fails #394

Description

@Mangepange

Description:

When applying an ElementStyle with bound property values on a column, it does not seem to apply the values until the bound value is updated.

Some notes:

  • If the Setters use actual values instead of x:Bind expressions, they are applied correctly.
  • There's a bunch of messages like this in the Ouput: Microsoft.UI.Xaml.dll!00007FFB11A766D0: 80070057 - E_INVALIDARG. They disappear if the Style is removed.
  • I tried changing to Binding instead of x:Bind, but I couldn't get it to work at all.
  • It is it not only on CheckBox columns, this ElementStyle on the TableViewTextColumn fails as well: <Setter Property="IsTextSelectionEnabled" Value="{x:Bind isEnabled.IsOn, Mode=OneWay}" />
  • I'm not sure if this is a TableView issues, or if it's really a WinUI issue. But I'm leaning towards WinUI...

Steps to Reproduce:

Adjust the EditingPage.xaml in the sample application to this.

        <controls:SamplePresenter Description="Showcasing cell value editing functionality." Header="Editing">
            <controls:SamplePresenter.Example>
                <tv:TableView AutoGenerateColumns="False" ItemsSource="{Binding Items}">
                    <tv:TableView.Columns>
                        <tv:TableViewTextColumn Binding="{Binding FirstName}" />
                        <tv:TableViewCheckBoxColumn Binding="{Binding IsActive}">
                            <tv:TableViewCheckBoxColumn.ElementStyle>
                                <Style TargetType="CheckBox">
                                    <Setter Property="IsEnabled" Value="{x:Bind isEnabled.IsOn, Mode=OneWay}" />
                                    <Setter Property="Content" Value="{x:Bind textBox.Text, Mode=OneWay}" />
                                </Style>
                            </tv:TableViewCheckBoxColumn.ElementStyle>
                        </tv:TableViewCheckBoxColumn>
                    </tv:TableView.Columns>
                </tv:TableView>
            </controls:SamplePresenter.Example>
            <controls:SamplePresenter.Options>
                <StackPanel VerticalAlignment="Top">
                    <TextBox x:Name="textBox" Text="TestInput" Width="200" />
                    <ToggleSwitch x:Name="isEnabled"
                                  Header="Is enabled"
                                  IsOn="False"
                                  OffContent="False"
                                  OnContent="True" />
                </StackPanel>
            </controls:SamplePresenter.Options>
        </controls:SamplePresenter>

Expected behavior:

The styled properties should apply the bound values from start, and not just when updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions