Search code examples
wpfeventsevent-handlingbehavioruielement

The right event to detect a moving UIElement inside a Canvas


I have a Rectangle within a Canvas. The rectangle has the MouseDragElementBehavior attached to it, so it can move freely within the canvas.

I need to do certain calculations when the smallest changes happen in the position of the rectangle, but i can not find a single best event.

So far I have resorted to MouseMove event for the rectangle which is an overkill. Any alternative?


Solution

  • You should base on the events from MouseDragElementBehaviour class, DragBegun, DragFinished and Draggging.