There are 4 ListBox, of three of which you can drag and drop items into the fourth, and not to move, but to copy. How to register events to host ListBox? ListBox events, from which to drag, registered. from one listbox:
<ListBox x:Name="listhelmets" Height="214" Width="248" ItemsSource="{Binding ListHelmets}" IsSynchronizedWithCurrentItem="True" Canvas.Left="464"Canvas.Top="37" PreviewMouseDown="helmet_MouseDown1" PreviewMouseLeftButtonDown="helmet_PreviewMouseLeftButtonDown" DragLeave="helmet_DragLeave" PreviewMouseMove="helmet_PreviewMouseMove" SelectedValuePath="protection"> <ListBox.ItemTemplate > <DataTemplate > <StackPanel Orientation="Horizontal"> <Image Source="{Binding Path=Image}" Width="56" Height="61"/> <TextBox Height="30" Width="30"> <Binding Path="protection" /> </TextBox> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> in that:
<ListBox x:Name="listHero" Height="148" Width="158" <ListBox.ItemTemplate > <DataTemplate > <StackPanel Orientation="Horizontal"> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> for the first listbox:
private void helmet_MouseDown1(object sender, MouseButtonEventArgs e) { _startPoint = e.GetPosition(null); } private void helmet_PreviewMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) return; Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if (Math.Abs(diff.X) <= SystemParameters.MinimumHorizontalDragDistance && Math.Abs(diff.Y) <= SystemParameters.MinimumVerticalDragDistance) return; var lst = sender as ListBox; var li = FindAnchestor<ListBoxItem>((DependencyObject)e.OriginalSource); Console.WriteLine("move " + li); if (li == null) return; var str = lst.ItemContainerGenerator.ItemFromContainer(li); var data = new DataObject("txt", str); var res = DragDrop.DoDragDrop(li, data, DragDropEffects.All); if (res == DragDropEffects.Move) (lst.ItemsSource as IList).Remove(str); } static T FindAnchestor<T>(DependencyObject current) where T : DependencyObject { do { if (current is T) return (T)current; current = VisualTreeHelper.GetParent(current); } while (current != null); return null; } UPDATE private void listHero_Drop(object sender, System.Windows.DragEventArgs e) { var o = e.Data.GetData("txt"); var lst = sender as ListBox; (lst.ItemsSource as IList).Add(o); e.Effects = DragDropEffects.Move; } private void ListHero_OnDragEnter(object sender, System.Windows.DragEventArgs e) { if (e.Data.GetDataPresent("txt")) e.Effects = DragDropEffects.Move; }`