Drag/Drop Multiple GridRow Items

3 posts, 0 answers
  1. John
    John avatar
    4 posts
    Member since:
    Jul 2013

    Posted 07 Aug 2013 Link to this post

    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. Nick
    Nick avatar
    593 posts

    Posted 08 Aug 2013 Link to this post

    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! 

    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 >>
  3. DevCraft banner
  4. John
    John avatar
    4 posts
    Member since:
    Jul 2013

    Posted 08 Aug 2013 Link to this post

    Ah perfect, thanks a bunch Nik.
Back to Top