-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Added ItemsControl.ItemsSource. #10590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
`ItemsControl` now works more like WPF, in that there are separate `Items` and `ItemsSource` properties. For backwards compatibility `Items` can still be set, though the setter is deprecated. `Items` needed to be changed from `IEnumerable` to `IList` though.
To allow binding both `ItemsControl.Items` and `ItemsSource` we need to support multiple `InheritDataTypeFromItems` attributes.
It's a view so makes sense to expose the read-only view interface.
be6a4ed to
2c56019
Compare
|
Ready for review, I think. |
|
You can test this PR using the following package version. |
How about breaking it and dropping the support for binding to Items, then change the type of Items to ItemCollection? |
Together with a specialized error message telling to bind to ItemsSource when trying to bind to Items instead of some cryptic or general error, that sounds like a good idea. Not showing a specific error would make it confusing as everyone first learned to use Items in Avalonia. |
|
I agree with above. I think changing the setter to throw an error that says change to ItemsSource is the best. Then in the future, the setter and DirectProperty can be removed without really being a breaking change. Since most binding usages are in Xaml, how noticeable is it that binding (or setting |
|
The feedback we've been getting from customers is that port a large project from 0.10.x to 11.x results in an almost overwhelming number of compile errors. Given that I'm 100% open to making |
How painful would it be to revert this change if the complaints are getting too much? |
Unlike other breaking changes, this one can be fixed easily with a simple find-and-replace. |
|
I've spoken to one of the customers who gave us that feedback and they feel that this wouldn't be a particularly bad breaking change. Given that, and the feedback here so I think we'll be ok to remove the We should do it in a subsequent PR though I feel, so it can potentially be reverted if we get more feedback. |
danwalmsley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM: Agreed YOLO to get this tested
What does the pull request do?
Adds
ItemsControl.ItemsSourcewith a similar behavior to WPF/UWP:ItemsControl.Itemsis now of typeIListso that the collection can be modified usingAdd/RemoveetcItemsControl.ItemsSourceis set,Itemsgoes into read-only mode and functions as a view over the items sourceItemsSourceis not initialized with an empty collection, it can be a styled propertyThere is one main difference from WPF/UWP, added for backwards compatibility:
Itemsproperty can still be bound and set (though this is deprecated). In this case, the items collection can still be accessed via the (pre-existing)ItemsViewproperty. For this reasonItemsis of typeIListand notItemCollectionTo allow both
ItemsandItemsSourceto be bound, I had to add support for multipleInheritDataTypeFromItemsattributes to be applied to a property. In this case that won't be a problem because only one can be set, though I'm not sure if it could could cause confusion in future?Doesn't correct usages of
ItemstoItemsSourceexcept where necessary (i.e.IEnumerablewas being assigned toItems). Done in a separate PR as it's a big noisy changeDoesn't change the name of the
Itemsproperty or add anItemsSourceto otherItemsControl-like controls. That can also be done later.Depends on #10589
Fixed issues
Fixes #7553
Fixes #10509