How to use DragDropManager with AllowDrop

11 posts, 0 answers
  1. Alfons
    Alfons avatar
    14 posts
    Member since:
    Mar 2012

    Posted 23 Aug 2012 Link to this post

    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
  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 24 Aug 2012 Link to this post

    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.

  3. Alfons
    Alfons avatar
    14 posts
    Member since:
    Mar 2012

    Posted 29 Aug 2012 Link to this post

    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;
    }
  4. Swapnil
    Swapnil avatar
    10 posts
    Member since:
    Feb 2018

    Posted 28 Mar 2018 Link to this post

    How to use Arrow Cue with DragDropManager 
  5. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2164 posts

    Posted 29 Mar 2018 Link to this post

    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.
  6. Swapnil
    Swapnil avatar
    10 posts
    Member since:
    Feb 2018

    Posted 29 Mar 2018 in reply to Martin Ivanov Link to this post

    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

  7. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2164 posts

    Posted 02 Apr 2018 Link to this post

    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.
  8. Swapnil
    Swapnil avatar
    10 posts
    Member since:
    Feb 2018

    Posted 11 Apr 2018 in reply to Martin Ivanov Link to this post

    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

  9. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2164 posts

    Posted 12 Apr 2018 Link to this post

    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.
  10. Swapnil
    Swapnil avatar
    10 posts
    Member since:
    Feb 2018

    Posted 13 Apr 2018 in reply to Martin Ivanov Link to this post

    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. 

  11. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2164 posts

    Posted 15 Apr 2018 Link to this post

    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.
Back to Top