Drag and Drop between TreeView and RadGrid

2 posts, 0 answers
  1. Ivan
    Ivan avatar
    1 posts
    Member since:
    Sep 2017

    Posted 06 Oct 2017 Link to this post

    Hello ! I know there are a lot of topics about this but i do have a issue with drag and rop . 
    I have a RadTreeView with sting data . The effect i`m looking for is to drag certain string from the TreeView into a Cell of the RadGrid . Each cell to be able to be with different content . 

    The tree view is just simple Tree view with data .

    I want to able only to drag and drop from TreeView to Grid not the other way around 

    Thanks in advance  !




  2. Martin Ivanov
    Martin Ivanov avatar
    1549 posts

    Posted 11 Oct 2017 Link to this post

    Hello Ivan,

    To achieve your requirement you can use the built-in drag/drop feature of RadGridView and DragDropManager to handle the drop in the RadGridView cells. Here are some steps which you can try.
    1. Enable the drag/drop in RadTreeView. You can do that by setting its IsDragDropEnabled property to True.
    2. Subscribe to the DragDropManager.Drop event and based on the corresponding data edit the cell content.
    3. You have two options for the Drop event. You can subscribe it directly to RadGridView and used ParentOfType<T>() method on the argument OriginalSource to get the GridViewCell element and updated it or its DataContext. The second option is to use the CellLoaded event of RadGridView and subscribe the Drop event to each cell separately.

    Additionally you can check the DragDropTreeViewToControls and DragDropWithLines SDK example.

    I hope this helps.

    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top