PanoramaElement DragDropService

3 posts, 0 answers
  1. Paul
    Paul avatar
    35 posts
    Member since:
    Aug 2015

    Posted 02 Jun 2016 Link to this post


    I have a Panorama with one Group (Group A) that contains a few tiles. I have changed the AllowDrag and AllowDrop for allow of these tiles to false to prevent Users from rearranging "Group A" tiles. At run-time, more groups and tiles are dynamically added based on individual user setting files. I am using the panorama.PanoramaElement.DragDropService.PreviewDragOver event to prevent users from dragging dynamically added tiles to "Group A".

    First I get the position of the cursor on the Panorama using panorama.PointToClient(MousePosition). Then I get the left most Group (Group B) that is not "Group A" and set the EventArgs.CanDrop to false if the cursor is left of "Group B's" ControlBoundingRectangle.Left.

    However, I found that if you drag a tile by first clicking on the right most edge of the tile and position the cursor just to the right of "Group B's" ControlBoundingRectangle's left edge, most of the tile hovers over the "Group A" but the cursor is within "Group B" and EventArgs.CanDrop is set to true. So when the user release the mouse, it puts the tile in "Group A".

    I looked at panorama.PanoramaElement.DragDropService.PreviewDragDrop and the EventArgs.DropLocation.X was 165 when in the panorama.PanoramaElement.DragDropService.PreviewDragOver the panorama.PointToClient(MousePosition).X was 250 (under 250 is when EventArgs.CanDrop is set to false).

    How can I determine if a tile is going to be dropped into "Group A" and cancel or prevent it?

  2. Paul
    Paul avatar
    35 posts
    Member since:
    Aug 2015

    Posted 02 Jun 2016 in reply to Paul Link to this post

    Of course I would solve it just after posting this.

    In the event panorama.PanoramaElement.DragDropService.PreviewDragOver, I cast the sender to TileDragDropService and then check if the TileDragDropService.DropLocation is within "Group A's" ControlBoundingRectangle. If so, I set the EventArgs.CanDrop to false;

  3. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4170 posts

    Posted 07 Jun 2016 Link to this post

    Hello Paul,

    Thank you for writing. 

    I am glad that you have a suitable solution for your case. Indeed, the TileDragDropService.DropLocation property is the correct way to check where exactly you are dragging over. Feel free to use the TileDragDropService.DropTarget as well.

    I hope this information helps. Should you have further questions I would be glad to help.

    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top