Drag and Drop in a WPF ListView

I am using a WPF ListView where SelectionMode is Extended (you can select multiple items only by pressing ctrl). I need to implement D&D between two ListViews. To execute the drag event, I used the DragItem event in WinForms, but such an event is not provided in wpf. I decided to use ListViewItem PreviewMouseDownClick

private void ListViewItemMouseDownClick(object sender, MouseButtonEventArgs e) { if (!this.AllowDragDrop) { return; } DragDrop.DoDragDrop( ListViewItemsCollection, this.SelectedItems, DragDropEffects.Copy | DragDropEffects.Move); } 

Unfortunately, this solution has an error: one element works (without pressing Ctrl). However, I need to double-click to select an item while ctrl is pressed to select multiple items. There is no difference when using ListView PreviewMouseDown or ListViewItem PreviewMouseDown. Any ideas how to solve the problem?

+4
source share
1 answer

Found a solution that works like chram: social.msdn.microsoft.com . I joined it with the code from the moncadad link. Thanks!

-1
source

All Articles