Skip to content

ListBoxItem.IsSelected Binding does not work anymore with preview5 #10249

Closed
@llfab

Description

@llfab

Describe the bug
I am binding a ListBoxItem's IsSelected property to my data model of the item as follows:

          <ListBox SelectionMode="Single, Toggle" 
                   Items="{TemplateBinding Items}" 
                   SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}"
                   ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                   ScrollViewer.VerticalScrollBarVisibility="Auto">
            <ListBox.Styles>
              <Style Selector="ListBoxItem">
                <Setter Property="IsEnabled" Value="{Binding IsSelectable}" />
                <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                ...

Originally I even had

<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />

to receive the changed selection directly in the items data model.

This has worked in preview4 but is not working anymore in preview5. As I checked in the Debugger, the IsEnabled property works nicely and the property getter in the data model is called. For IsSelected neither the getter nor the setter (if used with TwoWay) is called.

To Reproduce
as above

Expected behavior
Getter and setter for the data model property should be called

Desktop (please complete the following information):

  • OS: Windows 10
  • Version [11.0.0-preview5]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions