DragVisual position relative to cursor

5 posts, 1 answers
  1. Vincent
    Vincent avatar
    8 posts
    Member since:
    Mar 2012

    Posted 03 Dec 2012 Link to this post

    Hi,

    I use an Image that is shown when dragging:
    args.DragVisual = new ContentControl { Content = MyImage, Width = 25, Height = 25 };
    
    This image always shows up at a certain position relative to the cursor. Can I influence this position? I tried DragVisualOffset but - maybe I used it incorrect - that didn't result in a change of position. Thanks in advance, Vincent
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 03 Dec 2012 Link to this post

    Hello Vincent,

    You can use the DragVisualOffset property in combination with the RelativeStartPoint properties of the DragInitializeEventArgs to achieve the desired effect. 

    Hope this helps! 

    Regards,
    Nik
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Vincent
    Vincent avatar
    8 posts
    Member since:
    Mar 2012

    Posted 03 Dec 2012 Link to this post

    Hello Nik,

    the property RelativeStartPoint has an internal setter which I therefore can't change in the OnDragInitialize eventhandler which is passed to the DragDropManager:

    DragDropManager.AddDragInitializeHandler(control, OnDragInitialize, true);
    

    Should I change this property (together with DragVisualOffset) somewhere else instead of in this handler? 

    Kind regards,
    Vincent
  5. Answer
    Nick
    Admin
    Nick avatar
    593 posts

    Posted 03 Dec 2012 Link to this post

    Hello Vincent,

    The RelativeStartPoint property gives you the relative coordinates of the mouse pointer when starting a drag operation. You cannot set it. You can use it to calculate your own offset, and set it to the DragVisualOffset propery.

    Hope this helps! 

    Kind regards,
    Nik
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Vincent
    Vincent avatar
    8 posts
    Member since:
    Mar 2012

    Posted 04 Dec 2012 Link to this post

    Hi,

    the reason it didn't work in my case was that I probably used absolute X,Y-coordinates instead of calculated relative to RelativeStartPoint. I found the right piece of code in this topic:
    http://www.telerik.com/community/forums/silverlight/diagram/drop-event-of-raddiagram-is-not-working.aspx

    Thanks,
    Vincent
Back to Top
UI for WPF is Visual Studio 2017 Ready