Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

DragMoveBehavior

$
0
0

Hi everybody!

I'm coding a behavior (Interaction behavior) which is basic idea is to make any UIElement draggable with the mouse. In order to make it flexible enough, I thought of applying a TranslateTransform to the target element, so you don't have to have a Canvas as a parent container.

I made the behavior to add a Adorner to the AdornerLayer in order to show some kind of visual feedback that tell the user the object is in "drag mode". This adorner consists of a semitransparent Thumb control. 

The idea is that, when you drag the Thumb (DragMove), the delta (increment/decrement) is replicated in the underlaying target (the actual element to be moved). Example: if the Thumb is dragged 2 pixels to the right, I do TranslateTransform.X += 2

I tested it and was very upset: when you drag the element a little, the movement is really smooth, but for bigger X / Y, the element and Adorner (Thumb) start to swapping like mad! 

It appears the DragMove receives deltas that vary incorrectly, from negative values to positive, but I just drag in one direction. This is: the Delta is incorrect.

Was could be the problem? The Thumb itself receiving bad coordinates?

Thanks in advance! I can upload the code if you want to see it working. It's kind of simple.

BTW, Merry Christmas all!


Desde España / From Spain



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>