Retrieving cursor position relative to dragged element

2 posts, 0 answers
  1. Miłosz Cechnicki
    Miłosz Cechnicki avatar
    34 posts
    Member since:
    Sep 2009

    Posted 06 Sep 2012 Link to this post

    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
  2. Nick
    Nick avatar
    593 posts

    Posted 10 Sep 2012 Link to this post


    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,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top