DotNetKit.Wpf.AutoCompleteComboBox icon indicating copy to clipboard operation
DotNetKit.Wpf.AutoCompleteComboBox copied to clipboard

Properly synchronize the current selected item - Improve and fix #28

Open kvpt opened this issue 1 year ago • 2 comments

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 #27 with the benefit to not impact the existing CollectionView use case.

kvpt avatar May 11 '23 15:05 kvpt

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.

vain0x avatar May 12 '23 16:05 vain0x

Could you tell me how do you use CollectionView to reproduce this? I'm trying to reproduce as in a commit https://github.com/vain0x/DotNetKit.Wpf.AutoCompleteComboBox/commit/0c9fbcfaa9e7f320e77a2b482d78d159f462b3fb (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 (https://github.com/vain0x/DotNetKit.Wpf.AutoCompleteComboBox/pull/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.

kvpt avatar May 15 '23 23:05 kvpt