Deny drop based on data in viewmodel

4 posts, 0 answers
  1. Ramon
    Ramon avatar
    2 posts
    Member since:
    Nov 2017

    Posted 16 Nov Link to this post

    Hi all,

    we are trying out Telerik drag and drop. We want to drag between 2x itemslist and a DockPanel. To be able to use Telerik drag visualizer we converted both the itemslist to a ListBox (not 100% what we wanted though, because listbox looks different).
    This way we get a 'shadow' of the item we drag during the dragging. And an arrow indicating we can move the item (or red circle if denied).

    The problem now is we want to deny certain drops in the dockpanel based on the data in our viewmodel. How can we accomplish this?
    I can catch the events of the dockpanel like OnElementDragEnter, but I cannot set the e.Effects property to none. Also I don't have options class in my e.data object (like in your treeview example).

    Also tried to set the dockpanel.allowdrop to false during drag. That works, but then the next time the drag over event wont fire again :(.

    (the way we did this before Telerik components was just set the DragDropEffects.Effects to DragDropEffects.None)

     

    Thanks in advance

  2. Stefan
    Admin
    Stefan avatar
    805 posts

    Posted 20 Nov Link to this post

    Hello Ramon,

    Thank you for the detailed description of your setup.

    Speaking generally, you can disable dropping a given item by implementing a custom ListBoxDragDropBehavior. By overriding its CanDrop method you should be able to manipulate whether a given element can be dropped or not. Can you please check this out?

    In case further assistance is needed, feel free to approach me.

    Regards,
    Stefan
    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.
  3. Ramon
    Ramon avatar
    2 posts
    Member since:
    Nov 2017

    Posted 21 Nov in reply to Stefan Link to this post

    hi Stefam,

     

    thanks for your answer. How can i apply such a behaviour to a dockpanel? I cannot find any example for this scenario. 
    Or am i forced to rewrite my code to a ListBox instead of a DockPanel?

    Thanks in advance.

     

  4. Stefan
    Admin
    Stefan avatar
    805 posts

    Posted 23 Nov Link to this post

    Hi Ramon,

    As RadListBox's DragDropManager accepts only a ListBoxDragDropBehavior, dropping on RadDocking would not be possible with it. Please, excuse me for misguiding you. In order to achieve your goal, you can subscribe to the events of DragDropManager. For example, you can use the DragOver one and set the DragDropEffects through the Effects property of the event arguments to None. Then you can set the Handled property to true and terminate the execution of the event handler through a return statement. Can you please check it out?

    I hope you find this helpful. Of course, feel free to update me should you need further assistance with the implementation.

    Regards,
    Stefan
    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