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

PanoramaElement DragDropService

2 Answers 68 Views
Panorama
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 02 Jun 2016, 05:39 PM

Hello,

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 Answers, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 02 Jun 2016, 05:50 PM

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;

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Jun 2016, 08:46 AM
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.

Regards,
Dess
Telerik
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.
Tags
Panorama
Asked by
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or