Using the new DragDropManager, i.e. Windows approach

3 posts, 0 answers
  1. Jeff
    Jeff avatar
    7 posts
    Member since:
    Nov 2010

    Posted 11 Oct 2011 Link to this post

    I'm using the new DragDropManager and trying to stay as close to the standard Windows/WPF approach as much as possible.  Most of the examples here use the RadDragAndDropManager, and I haven't been able to find examples using the new approach.

    I have a form with 2 grids (i.e. RadGridView).  There are 2 possible drag/drop scenarios:

    Scenario 1. Drag a row from the left grid, and drop onto a row in the right grid, in order to create an association.  In this scenario I need to determine how to  Provide a visual indicator of the drop target row.  This could be achieved by displaying the default mouse-hover highlight on a row, which seems to be turned off during drag/drop.  Is there a way to selectively turn this on and off from within the DragEnter and DragLeave events?

    Scenario 2. Use drag/drop to reorder rows within either grid.   In this scenario I need to determine how to display a visual indicator of where the dragged row will be moved to, via an indicator line between the rows.  I notice that the RadTreeListView contains a nice template for this.  I can use the RadTreeListView instead of the RadGridView to take advantage of this.  However this indicator seems to be always on or off based on the IsDragDropEnabled property.  Can this template be toggled on/off from within DragEnter and DragLeave events?  Also how can I determine if the drop point is before or after the target row.

    You'll notice that the right grid handles both scenarios, depending on the drag source.  Here is the DragOver handler which provides feedback on what effect (if any) the drop would have.  

    private static void OnRightGridDragOver(object sender, DragEventArgs e)
                e.Effects = DragDropEffects.None;

                GridViewRow row = FindVisualParent<GridViewRow>(e.OriginalSource as UIElement);
                Attribute attribute = row == null ? null : row.Item as Attribute;
                IDataObject dataObject = (IDataObject)e.Data;

                if (dataObject.GetDataPresent(typeof(Field)))
                    if (attribute != null && attribute.Children.Count == 0)
                        e.Effects = DragDropEffects.Link;
                else if (dataObject.GetDataPresent(typeof(Attribute)))
                    e.Effects = DragDropEffects.Move;
                e.Handled = true;

    Also I notice that unlike the RadDragAndDropManager, the new DragDropManager doesn't seem to support auto scrolling of a list. How would that be handled?

    Thanks for your help.
  2. Tsvyatko
    Tsvyatko avatar
    863 posts

    Posted 17 Oct 2011 Link to this post

    Hello Jeff,

     I have prepared simple project that illustrates how to achieve this. The DropIndicator is based on this help article, however it uses the new DragDrop events.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Jeff
    Jeff avatar
    7 posts
    Member since:
    Nov 2010

    Posted 18 Oct 2011 Link to this post

    Hi Tsvyatko, Thanks for the sample code.  I think this is just what I was looking for.  I ran into one problem, which is that it doesn't seem to work with the RadTreeListView.  I should have specified that in my original question above.  When the drop position indicator is attached, the children don't expand anymore.


Back to Top