This is a migrated thread and some comments may be shown as answers.
Using the new DragDropManager, i.e. Windows approach
2 Answers 140 Views
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 11 Oct 2011, 10:58 PM
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 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 17 Oct 2011, 02:56 PM
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.

Regards,
Tsvyatko
the Telerik team

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

0
Jeff
Top achievements
Rank 1
answered on 18 Oct 2011, 10:55 PM
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.

Thanks,
-Jeff


Asked by
Jeff
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or