Drag visual is far away from the pointer

The objects to drag are placed in a Xaml grid with 50 rows and 50 columns. The fields are 96 of 96 points.

The drag visual that is shown during the drag operation is attached to the pointer, but far away from the pointer (look at the attached picture).

Is it possible, to keep the visual near from the pointer? Is there a mechanism between the pointer and the drag visual? In this case, the distance to the visual becomes greater the further away the pointer form the first field (top – left) ist. There is an explanation for this behavior?

enter image description here

  • Not sure I’m following. However, does the offset from what you see relative to what you want say the same for close and far cases? If you move the window to the corners of the screen, does the offset stay the same? If the former seems wrong, check your calculations. If the latter, check if you are working in screen or client coordinates

    – 

  • It might be easier to help with minimal reproducible code.

    – 

  • @Flydog57, thanks for your evaluation. It seems there is a connection. If the first field is moved in the window to the top left corner of the screen, the position of the drag visual is perfect, also near to the mouse pointer. The drag function is enabled by the property CanDrag or by the method StartDragAsync of the UiElement. The system calculate the distance to the visual. .. any idea, how i can correct the drag visual distance?

    – 

  • You need to do a screen coordinates to client coordinates transformation. I’m not a WPF guy, but it shouldn’t be hard to figure this out

    – 

  • Ok thanks, i try to find out, i know the lead. The application is a windows app based on Net6

    – 

Leave a Comment