Drag a thumb to move textbox, the deviation between the drag preview position and the mouse position becomes larger and larger

企业微信截图_20250923201815.png Hello everyone, I want to implement a feature where dragging a Thumb changes the position of a TextBox. I placed a Thumb and a DragVisual in the Adorner of the TextBox. However, during runtime, I noticed that as the mouse is dragged farther, the distance between the mouse and the DragVisual keeps increasing. But after printing the values, I found that the distance between the mouse and the DragVisual hasn't changed, as it is calculated using coordinates relative to the window. Could anyone help me understand the reason for this?



Attachment: wechat_20250923_200826_218_e6f126f0.png


1 Reply

KA Karthick Arjunan Syncfusion Team September 30, 2025 06:48 AM UTC

Hi, 


Thank you for sharing the details and the screenshot. Based on the provide information, we understand you're implementing a drag feature using a Thumb and a DragVisual placed in an Adorner over a TextBox. You've observed that during dragging, the distance between the mouse pointer and the drag preview increases.

We’ve created a simplified sample based on your description and were able to reproduce the reported behavior using the standard WPF TextBox control. This confirms that the issue is not specific to the IntegerTextBox control.


In our sample, the Thumb is placed to the right of the TextBox and acts as the drag handle. When the user clicks and drags the Thumb, a semi-transparent drag visual appears and follows the mouse pointer using e.GetPosition(window) for precise alignment. The original TextBox remains hidden during the drag and is moved to the drag visual’s final position once the drag completes.  This setup ensures the drag visual stays synchronized with the mouse and avoids cumulative offset errors.

 
We’ve attached a sample project and a demo video for your reference. Please review them and let us know if we’ve misunderstood any part of your requirement. If possible, kindly share a modified sample or a video from your end to help us better understand and address the issue.


Regards,

Karthick Arjunan


Attachment: DraggingDemo_dfef30eb.zip

Loader.
Up arrow icon