Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
Drag and Drop multiple items FROM Listbox
posted

I am interested in being able to drag multiple items from a SL Listbox to a xamDataTree using the DragDropManager.  Is that possible? Even though I have my listbox set to SelectionMode="Extended", when I start dragging the DragDropStartEventArgs Data property is set to only one of the selected items. I have seen other posts about dragging multiple XamGridRows, but none of them seem to apply to a ListBox. Any help would be appreciated.

<ListBox x:Name="lbFilteredContacts"
             ItemsSource="{Binding FilteredContacts}"
             SelectionMode="Extended"
             MaxHeight="300"
             MinWidth="300"
             Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="5"
             Visibility="{Binding ContactListVisible}">
         <ListBox.ItemTemplate>
              <DataTemplate>
                   <StackPanel Orientation="Horizontal">
                       <Image Source="{Binding image}" Height="16" Width="16" Margin="5"/>
                        <TextBlock Text="{Binding fullName}" Margin="5"/>
                        <ig:DragDropManager.DragSource>
                            <ig:DragSource x:Name="dsListBox" 
                                 IsDraggable="True"
                                 Drop="dsListBox_Drop"
                                 DataObject="{Binding}"
                                 DragStart="dsListBox_DragStart"/>
                            </ig:DragDropManager.DragSource>
                      </StackPanel>
                   </DataTemplate>
                </ListBox.ItemTemplate>
             </ListBox>
Parents
  • 138253
    Verified Answer
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically in the DragStart event handler I set the Drag’s Data to be the SelectedItems, and also create a DataTemplate for the DragTemplate, so I can show all the selected Items. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

    DragDropMultipleItems.zip
Reply Children