punker76/gong-wpf-dragdrop

Multiselection problem

Opened this issue · 0 comments

Hello,

I am using this library (that I like a lot) with a DataGrid and I am experiencing a strange behaviour with multiselection, if I click on a selected item when more then one is selected, the selection change and only the item I clicked on remain selected.

Investigating in the code of DragDrop.cs I found this comment in the method DragSourceDown:
// If the sender is a list box that allows multiple selections, ensure that clicking on an // already selected item does not change the selection, otherwise dragging multiple items // is made impossible.
and the control is done with itemsControl.CanSelectMultipleItems() then in DragSourceUp there is condition to handle the multiselection
(Keyboard.Modifiers & ModifierKeys.Control) != 0 || itemsControl is ListBox listBox && listBox.SelectionMode == SelectionMode.Multiple
and since there is a check on the ListBox in my case with the DataGrid my multiselection is discarted.

I believe there is a mismatch in this two methods, either the multiselection is handled only for the ListBox or for every controls that satisfy CanSelectMultipleItems(), but the condition should be the same in both methods.
Anyway it is probably correct to handle it only for the ListBox since other ItemsControls could not need selection when items are clicked, in my case with the DataGrid I use checkboxes on row header and I don't want the selection to change by clicking on the DataGridCell of the items.

Does any of this make sense?
Let me know if something can be done to make this behaviour better.

Thanks!