Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
Canceling a Drop Event within the Drop Handler
posted

I'm performing Drag & Drop within a XamDataTree where there are "Product" nodes that can contain many "License" nodes. Currently, a user can drag a License to any Product node, but I want to only a allow a user to drag a License node to the correct Product for the license. I'm overriding the DragEnter and Drop events, and I have some custom logic (based on the objects that the tree is bound to) that determines if the drop should be allowed. I know I can set the DragDropCancelEventArgs.Cancel variable to true in the DragEnter event, and this works, but I don't want to completely cancel the operation until the drop is attempted. However, if I call DragDropManager.EndDrag(true) in the Drop event, it does nothing.

Any ideas on how to get this to work?

Parents
No Data
Reply
  • 12875
    posted

    Hi Daniel,

    I would recommend that you use your method of determining if you want to drop the node to control whether you add the Child.   You wouldn't be canceling the event but you are in control of whether the node is dropped in the new location.

    There is a sample for dragging xamDataTree nodes with a tree structure on this forum thread.  Krasimir has a sample there that may be helpful to you.  In his case he is controlling position and whether or not the data type is of the correct data type before adding the node.

    http://es.infragistics.com/community/forums/t/57497.aspx

    You can acquire the target that you would be adding the child to by referencing the e.DropTarget.  And the e.OriginalDragSource references the element you are dragging.

    Then based on your requirements you add the node to the target's Nodes collection.

    Please let me know if you  have any questions.

     

Children