This is a migrated thread and some comments may be shown as answers.

Drag/Drop Multiple GridRow Items

2 Answers 227 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 07 Aug 2013, 08:23 PM
I'm hoping somewhere here on the forums can help me as I've searched all over (on the forums) and in the documentation and examples and are coming up dry. Right now I'm building a system in where the end-user can take a product (or products) from a RadGridView and drag them over to a RadTreeView which contains Categories and onto a RadTreeViewItem. 

The entire system as it stands works perfectly for a single GridViewItem but I need to be able to support multiple items. Unfortunately I have not been able to find any solution in the demos or on the forums (most posts are either WinForm related or use the deprecated RadDragDropManager). If anyone can shed some line on how I can handle multiple items with the newer DragDropManager that would be great.

Current code is attached.

private void CatalogManageCategoriesProductsDataGrid_OnDragInitialize(object sender, DragInitializeEventArgs e)
{
    ViewModels.DropIndicationDetails details = new ViewModels.DropIndicationDetails();
 
    var GridViewItem = e.OriginalSource as GridViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType<GridViewRow>();
    var data = GridViewItem != null ? GridViewItem.Item : (sender as RadGridView).SelectedItem;
    var payload = DragDropPayloadManager.GeneratePayload(null);
 
    details.CurrentDraggedItem = data;
 
    payload.SetData("DraggedData", data);
    payload.SetData("DropDetails", details);
 
    e.Data = payload;
 
    e.DragVisual = new DragVisual()
    {
        Content = details,
        ContentTemplate = CatalogManageCategoriesProductsDataGrid.Resources["ProductDragTemplate"] as DataTemplate
    };
 
    e.DragVisualOffset = e.RelativeStartPoint;
}

2 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 08 Aug 2013, 08:33 AM
Hi Alan,

The modification is actually quite simple. You just have to loop through the selected items of the Grid View and replace the CurrentDraggedItem property with a collection of items. 
The change is really straight forward so I think you shouldn't have difficulties implementing it, nevertheless don't hesitate to ask if you need any further help. 

Hope this helps! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Alan
Top achievements
Rank 1
answered on 08 Aug 2013, 11:47 AM
Ah perfect, thanks a bunch Nik.
Tags
DragAndDrop
Asked by
Alan
Top achievements
Rank 1
Answers by
Nick
Telerik team
Alan
Top achievements
Rank 1
Share this question
or