Configure ListBox in WPF so that I will be possible to select multiple items without holding CTRL key

Rasto picture Rasto · Jun 6, 2010 · Viewed 7.2k times · Source

I have a Listbox that allows user to select multiple items. Normally user can do that by holding CTRL key and clicking the item he or she wants to select.

Is it possible to configure this listbox so that the user will not have to hold the CTRL key when selecting items ? So that he or she will just click the item (without holding anything) and the item will be selected(diselected if it was selected previously) ?

Thank you

Answer

ChrisF picture ChrisF · Jun 6, 2010

Use

SelectionMode="Multiple"

From the MSDN:

The SelectionMode property determines how many items a user can select at one time. You can set the property to Single (the default), Multiple, or Extended. The following table described the behavior of these enumeration values.

Single The user can select only one item at a time.

Multiple The user can select multiple items without holding down a modifier key.

Extended The user can select multiple consecutive items while holding down the SHIFT key or non-consecutive items by holding down the CTRL key and clicking the items.