Skip to content

Conversation

@kvpt
Copy link

@kvpt kvpt commented May 11, 2023

The PR #28 caused a regression when using a CollectionView, when the CollectionView is bound the SelectionItem is reset.

There is two cases to consider :

  • There is an existing CollectionView, in this case let's the CollectionView handle it like before.
  • There is no CollectionView, so we create it, but after that, explicitly its position to -1, so no item is selected by default, this is for me the right approach to fix Changing ItemsSource selects the first item #27 with the benefit to not impact the existing CollectionView use case.

Ensure that the position of a created CollectionView is -1, so no item is selected by default.
@vain0x
Copy link
Owner

vain0x commented May 12, 2023

Thank you.

However this PR breaks in the situation of #28. It can reproduce with Test project by the following steps:

  • Input some text to filter (say, aa) and suggestion list is shown
  • Select one (Aaron)
  • Press the Reload button (i.e. assign new list to ItemsSource)

At this time, on main (v1.6.0) the SelectedItem is intact, on item-reset-fix it's cleared.


The PR #28 caused a regression when using a CollectionView, when the CollectionView is bound the SelectionItem is reset.

Could you tell me how do you use CollectionView to reproduce this? I'm trying to reproduce as in a commit 0c9fbcf (in vnext branch) but not reproduced.


Recently I feel that providing CollectionViewSource (#26) isn't right way perhaps. Instead, ask users to wrap ItemsSource with CollectionViewSource for each combobox instance. I would like to hear users thoughts.

@kvpt
Copy link
Author

kvpt commented May 15, 2023

Could you tell me how do you use CollectionView to reproduce this? I'm trying to reproduce as in a commit 0c9fbcf (in vnext branch) but not reproduced.

Sure, in my app I do two things,
I use a CollectionView (a ListCollectionView to be precise) directly
and I set the Selected Value in the code after the creating of the collection view.

Here the two changes in the test project that reproduce my issue.
image

image

I can perhaps modify my app to use a CollectionViewSource instead of a CollectionView but I don't need this new level of indirection and this was working fine previously so I'm a bit reluctant to do it.

Recently I feel that providing CollectionViewSource (#26) isn't right way perhaps. Instead, ask users to wrap ItemsSource with CollectionViewSource for each combobox instance. I would like to hear users thoughts.

I don't really have an opinion if it need to be supported or not directly by the component, but it certainly will be difficult to handle all the combinations and possible use cases.

vain0x added a commit that referenced this pull request May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing ItemsSource selects the first item

2 participants