RWS / Multiselect-ComboBox

The multi selection combo box is a WPF custom control with multiple item selection capabilities, along with customizable features to group, sort and filter items in the collection.
Apache License 2.0
182 stars 55 forks source link

Selecting all items results in a NullReferenceException #70

Closed molnarm closed 2 years ago

molnarm commented 2 years ago

Steps to reproduce:

  1. Start the example project
  2. Select the first item in the dropdown
  3. Scroll to the end of the list
  4. Press Shift and select the last item

Exception:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference is not set to an instance of an object.
  Source=Sdl.MultiSelectComboBox
  StackTrace:
   at Sdl.MultiSelectComboBox.Themes.Generic.MultiSelectComboBox.DropdownListBoxPreviewMouseUp(Object sender, MouseButtonEventArgs e) in C:\Repos\Multiselect-ComboBox\MultiSelectComboBox\Sdl.MultiSelectComboBox\Themes\Generic\MultiSelectComboBox.cs:line 1362

Disabling virtualization for the listbox solves the issue (and is still fast enough for my scenario), but a proper code fix would be great.

sdolhaor commented 2 years ago

The crash should be fixed in the latest build. However, a deeper issue remains: because the control is using virtualization internally, when the user Shift+selects a large set of items, some invisible in the UI, those that aren't visible won't be marked as selected. For now we've decided to keep this as is, as virtualization (optimization for loading many items) is important, and users can always Ctrl+select any number of items otherwise.