From 97ab9678f304a36848487b79e506bb417f561d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Karger=20=E3=83=84=20=E2=98=80?= Date: Fri, 8 Oct 2021 21:50:51 +0200 Subject: [PATCH] Merge pull request #409 from jizc/fix/multiselection Fixes ListBox multi selection & reduces amount of SelectionChanged events --- .../Utilities/ItemsControlExtensions.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/GongSolutions.WPF.DragDrop/Utilities/ItemsControlExtensions.cs b/src/GongSolutions.WPF.DragDrop/Utilities/ItemsControlExtensions.cs index d31253b2..bce7e498 100644 --- a/src/GongSolutions.WPF.DragDrop/Utilities/ItemsControlExtensions.cs +++ b/src/GongSolutions.WPF.DragDrop/Utilities/ItemsControlExtensions.cs @@ -340,12 +340,7 @@ public static void SetSelectedItem(this ItemsControl itemsControl, object item2S if (selectionMode != SelectionMode.Single) { - var itemsToDeselect = listBox.SelectedItems.Cast().Where(si => si != item2Select).ToArray(); - - foreach (var item in itemsToDeselect) - { - listBox.SelectedItems.Remove(item); - } + listBox.UnselectAll(); } try