Multiselect ListBox

2019-02-11 13:37发布

问题:

I'm having trouble in multiple items selection in an ListBox.

I've tried deriving new control from Selector and writing ListBox helper class which did not work (as expected).

The issue with Selector class is, it does not expose SelectedItems and it's hell to bind the property and manipulate it with selection changed event.

The issue with ListBox Helper class is, I'm getting the required data on multiple selection but it never hits the bound property.

Does anybody know a better way to implement multiselect listbox?

Thanks in advance...

回答1:

The ListBox has multiple selection already implemented. Just change SelectionMode property to Multiple or Extened.

You can use SelectedItems property to get all the selected items afterwards.