Skip to content

Trying to bind to ItemsControl.Items instead adds a Binding to Items. #10946

@grokys

Description

@grokys

Describe the bug

#10827 made ItemsControl.Items readonly, however as reported in that PR, there are no indications at compile time that this is no longer supported. Instead the XAML compiler adds a Binding object to the ItemsCollection.

Image

I think this is because the XAML compiler is treating the following two XAML snippets as equivalent:

<ItemsControl Items="{Binding Foo}"/>
<ItemsControl>
  <ItemsControl.Items>
    <Binding Path="Foo"/>
  </ItemsControl.Items>
</ItemsControl>

And so is creating a Binding object and adding it to Items with Items.Add(object?).

WPF does not behave in the same way: trying to assign a binding to ItemsControl.Items gives us:

The property "Items" does not have an accessible setter.

Desktop (please complete the following information):

  • Version: master

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions