-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Rewrite SelectionModel #4533
Rewrite SelectionModel #4533
Conversation
Handles only list selections, not nested selections.
- Inner list needs to be a non-generic `IList` because `IList<T>` is no covariant. - Moved out of the Repeater directory as it's now general-purpose.
A lot of these changes make sense. Removing IndexPath; however, cripples the usefulness of SelectionModel and as you stated, doesn't allow it to work in a hierarchy (TreeView). Removing IndexPath doesn't seem like a good idea to future-proof this API. IndexPath with a single int index isn't that complicated. |
The idea will be to add a
Heh, it's a lot more complicated than it first seems! |
As raising the event can cause the listeners to change.
`IEnumerable<T>` is not covariant for value types, so we need to use the non-generic `IEnumerable` everywhere under the hood to ensure we can work with both value and reference types.
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.
code style 👍 tested controlcatalog and found nothing wrong 👍 would need a deeper dive testing @danwalmsley
@Kermalis I wasn't targeting those issues specifically, as this PR was holding up a release, however it's possible it may have fixed some things. I plan to look into those issues again when I have a moment. |
What does the pull request do?
SelectionModel
as ported from WinUI has a number of problems:SelectedIndex
(Selection Model Issues #4496)IndexPath
for flat selection)TreeView
works (don't know what the child items are until theTreeViewItem
is materialized, so can't select non-expanded nodes)SelectedIndex
/SelectedItem
; instead returned first selectionSelectedItem
SingleSelect = true
BeginInit
/EndInit
logic had to be hacked into control (needs to be possible to setSelectedIndex
/SelectedItem
beforeItems
is assigned in XAML)This PR first reverts the changes introduced by the previous
SelectionModel
attempt and then rewritesSelectionModel
to:int
sSelectionModel
generic so that it can be used in ViewModels without casts everywhereSelectedIndex
AnchorIndex
work as expectedSelectedItem
SingleSelect = true
Source
is assigned work better, soBeginInit
can simply delay theSource
assigment until initialization is finishedNote that after this change,
TreeView
no longer has a selection model: it will remain reverted to its pre-SelectionModel
v1 state.It's still a WIP, left to do:
SelectedItems
to repopulate selection afterReset
(needs to be a way to turn it off for large collections)IsSelected
setSelection
to samples (were changed back toSelectedItems
when I reverted the previousSelectionModel
)Breaking changes
Yep, it's a breaking change :) Not so much from 0.9.x but the
SelectionModel
API has changed from the previous version shipped in the 0.10 previews.Fixed issues
Fixes #4496