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

How to use DragDropManager with AllowDrop

10 Answers 647 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Alfons
Top achievements
Rank 2
Alfons asked on 23 Aug 2012, 11:35 AM
Hi,

I am using the DragDropManager and I managed to get it working. Actually it is working too good. I set AllowDrop = true on only 2 controls, but I can drop the object on all controls.

1. I had hoped to get a Cursors.No on areas where AllowDrop wasn't set to true. How can I do that? Even better would be not to fire the OnDrop() event in this case.
2. If I always have to handle the OnDrop event: Is there a way I can find out in the OnDrop() and OnDragCompleted() method to see if the Drop was legitimate/successful or not?

Regards,

Alfons

10 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 24 Aug 2012, 03:00 PM
Hello,

The AllowDrop is inherited property so if you set it to true on a Grid for example, everything you put in that Grid will have AllowDrop = True. To workaround this just set it to false wherever you need. If it is set to false and you try to drop the dragged item there, the OnDrop event will not be fired.

If this is not the case please send us a sample project illustrating the issue.

Greetings,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Alfons
Top achievements
Rank 2
answered on 29 Aug 2012, 01:00 PM
Hi Rosen,

I guess I was mistaken. As you said, the AllowDrop does work. To change the cursor I used the following code:

void OnDragOver(object sender, DragEventArgs args)
{
    var ctrl = sender as Control;
    if (ctrl != null && ctrl.AllowDrop)
    {
        args.Effects = DragDropEffects.Move;
    }
    else
    {
        args.Effects = DragDropEffects.None;
    }
}
 
private void OnGiveFeedback(object sender, GiveFeedbackEventArgs args)
{
    if (args.Effects == DragDropEffects.Move)
    {
        args.UseDefaultCursors = false;
        args.SetCursor(Cursors.Hand);
    }
    else if (args.Effects == DragDropEffects.None)
    {
        args.UseDefaultCursors = false;
        args.SetCursor(Cursors.No);
    }
    else
    {
        args.UseDefaultCursors = true;
    }
 
    args.Handled = true;
}
0
Swapnil
Top achievements
Rank 1
answered on 28 Mar 2018, 05:55 PM
How to use Arrow Cue with DragDropManager 
0
Martin Ivanov
Telerik team
answered on 29 Mar 2018, 12:57 PM
Hello Swapnil,

Can you tell me what you mean by arrow cue? Is this the mouse cursor? Or the drag visual element? Or the small icon next to the cursor that shows the allowed drag/drop operation?

To change the mouse cursors while dragging you can subscribe to the DragInitialize or GiveFeedback events of the DragDropManager and set the Cursor property of the dragged element or use the SetCursor method of the GiveFeedbackEventArgs class. Here is an example for the both approaches:
private void OnElementGiveFeedback(object sender, Telerik.Windows.DragDrop.GiveFeedbackEventArgs e)
{
    e.SetCursor(Cursors.Arrow);
}
 
private void OnElementDragInitialize(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
    var element = (FrameworkElement)sender;
    element.Cursor = Cursors.Arrow;           
}

To change the drag visual you can set the DragVisual property of the DragInitializeEventArgs class.
private void OnElementDragInitialize(object sender, DragInitializeEventArgs e)
{
    e.DragVisual = myArrowShapeControl;
}

To change the allowed effects icon you can set the AllowedEffects property of the DragInitializeEventArgs class. 
private void OnElementDragInitialize(object sender, DragInitializeEventArgs e)
{
    e.AllowedEffects = DragDropEffects.Copy;
}

Regards,
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.
0
Swapnil
Top achievements
Rank 1
answered on 29 Mar 2018, 02:14 PM

Hi,

We have previously working functionality, where we drag from treeview and drop into schedular where we have use RadDragansDropmanager for create arrow using RadDragAndDropManager.GenerateArrowCue() which point from source to destination 

But as we upgrade into latest WPF telerik version we lost that functionality.

Now, We able to get same effect when we use RadDragAndDropManager.ExecutionMode = DragExecutionMode.Legacy but the schedular not able to recognize external source item.

We have use custom dragbehiviour for schedular to save and delete data by inheriting from ScheduleViewDragDropBehavior class.Which stop working when we used " DragExecutionMode.Legacy" setting for treeview

 

We are seeking help on how we can able to achieve the same

0
Martin Ivanov
Telerik team
answered on 02 Apr 2018, 10:06 AM
Hello Swapnil,

The new DragDropManager doesn't support the arrow cue feature. To achieve your requirement you can implement a custom drag visual and render the arrow shape manually on mouse move. Alternatively, you can define a panel above the controls that will drag/drop items and add a custom arrow shape in it. Then on drag/drop manually update the shape.

I hope that helps.

Regards,
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.
0
Swapnil
Top achievements
Rank 1
answered on 11 Apr 2018, 01:39 PM

Hi,

We are not sure hoe to implement this. Can you able to provide the demo?  

Please find attached image of the requirement.

 

Thanks,

Swapnil

0
Martin Ivanov
Telerik team
answered on 12 Apr 2018, 12:54 PM
Hello Alfons,

I prepared a small example that shows a possible approach that you can try. I hope it helps.

Regards,
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.
0
Swapnil
Top achievements
Rank 1
answered on 13 Apr 2018, 03:55 PM

Hi Martin ,

Thanks for the reply

We have try to implement same into our project. In our case we drag item from Tree view and drop to the Radschedular control. Using your suggestion we able to get the custom arrow as required but when we drop the same at schedular it not able to recognize the same.

We have implemented CustomScheduleViewDragDropBehavior which is inherit from ScheduleViewDragDropBehavior.

If we use the  DragDropManager.AddDragInitializeHandler, DragDropManager.AddDragOverHandler and DragDropManager.AddDragDropCompletedHandler handler over the treeView, Schedular Drop functionality stop working. 

0
Martin Ivanov
Telerik team
answered on 15 Apr 2018, 03:31 PM
Hi Swapnil,

I am afraid that without your implementation I cannot tell what is going on. Can you prepare some runnable code and post it here? Or open a new support ticket from your telerik.com account and share a runnable project there.

Regards,
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.
Tags
DragAndDrop
Asked by
Alfons
Top achievements
Rank 2
Answers by
Rosen Vladimirov
Telerik team
Alfons
Top achievements
Rank 2
Swapnil
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or