I’ve logged this as a feature request with two additions:
- A property to preserve the current ListBox selection when clicking empty space. This will be opt-in, so existing applications keep their current behaviour.
- A cancellable
SelectionChanging event that lets you inspect the current and proposed selections before the change is applied. Cancelling it will leave the existing selection intact and won’t raise SelectionChanged.
The event will cover mouse input, keyboard navigation and multiple-selection gestures. That means a rule preventing particular rows from being selected will also work when navigating with the keyboard or selecting a range.
I’ve chosen to keep the existing MouseDown signature because the behaviour you want to control is selection. Handling it at that level covers more ways of changing the selection and lets other mouse actions, such as resizing columns or using scrollbars, continue normally.