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

Retrieving cursor position relative to dragged element

1 Answer 123 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Miłosz Cechnicki
Top achievements
Rank 1
Miłosz Cechnicki asked on 06 Sep 2012, 08:48 AM
Hi,
In our application we are using Drag&Drop operation between RadTreeView and ListView. The ListView contains some GuidLines, to which dragged elements must be snapped. In order to determine that, we need to know the exact X and Y of the left upper corner of dragged item.
To achieve that, we calculate the current drag point relative to the listView:

p = transf.Transform(e.Options.CurrentDragPoint);

and the the point relative to dragged element (to get the location of mouse cursor relative to left upper corner of dragged element):
elem = cue.ItemContainerGenerator.ContainerFromItem(cue.Items[0]) <span style="color:blue;">as</span> <span style="color:#2b91af;">FrameworkElement</span>;
  
                        <span style="color:blue;">if</span> (elem != <span style="color:blue;">null</span>)
                        {
                            visualRoot = GetVisualRoot(elem);
                            transf = visualRoot.TransformToVisual(elem);
                            pointOnDraggedItem = transf.Transform(e.Options.CurrentDragPoint);
                        }

Everything worked fine in version 2011.3.1205.1040,

After migrating to 2012.3.725.1050 SL5 controls calculating the mouse position relative to dragged element (the 2nd code snippet).
The method TransfromToVisual returns always the same (invalid) values, no matter on which visual element the method is executed on.

Is there anything changed with placing the dragged element in the current visual tree?
Is there any way to get the mouse position relative to dragged element?

Thank You for Your help,
Best regards

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 10 Sep 2012, 02:20 PM
Hello,

May I ask you if you are using any customizations over the DragCue, like DragOffset, or anything else that could reflect on the positioning?
There have not been any changes in the DragCue container since 2011 Q2. In Silverlight the default Container is a popup wrapper.

Looking forward to your response! 

Kind regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DragAndDrop
Asked by
Miłosz Cechnicki
Top achievements
Rank 1
Answers by
Nick
Telerik team
Share this question
or