0
votes

I want the behavior of the WPF ListBox with the property SelectionMode set to "Extended". BUT, I want to block the feature to use "shift" to select multiple items at once.

Any ideas on how to achieve this?

The rationale

The background to this is that I am using a listbox to present items on a map. The ItemsPanel of the listbox have been replaced by a Canvas. Moving ListBoxItems around a Canvas?

So I don't want to modify the select behavior of an ordinary ListBox, what I want to do is to bring in a nice multi selection pattern into a "map" control built ontop of a ListBox.

1
What are you trying to accomplish? Your answer to that question may impact the answer you get below. Remember, you can also use the CTRL key to select multiple items, consecutive or not. Disabling shift just disables selecting a range at once, but you could select the same items individually using CTRL.Wonko the Sane

1 Answers

2
votes

It is generally unadvisable to change the default behaviour of controls as many users will be used to this behaviour. Having said that, surely you can get your desired effect (not being able to select ranges of items at once) from just using the ListBox.SelectionMode of Multiple instead. This enables users to select multiple items one by one and the Shift key has no effect.