I have a ListBox with multiple selection. And I am doing drag and drop operation in it. I used Ctrl+A to select all items. But once I have click an item to start drag, items got deselected. Is there any way to select/deselect listboxitem on mouse up.
Share
The ListBoxItem overrides its OnMouseLeftButtonDown and invokes a method on the containing ListBox that handles the selection. So if you want to mouse down on a selected listbox item and initiate a drag you will need to start that before this happens on the ListBoxItem. So you might try handling the PreviewMouseLeftButtonDown on the ListBox and checking the e.OriginalSource. If that is a ListBoxItem or an element within the listbox item (you’ll need to walk up the visual tree) then you can initiate your drag operation. E.g.