Skip to content

MouseDragElementBehavior

branh edited this page Dec 4, 2018 · 2 revisions

MouseDragElementBehavior allows a FrameworkElement (such as a Button or Rectangle) to be dragged around the screen using the mouse.

The position of an element controlled by this behavior may also be set with the X and Y properties, or constrained to the bounds of its' parent container if ConstrainToParentBounds is set to true.

Sample Code

Xaml

<Rectangle>
  <Behaviors:Interaction.Behaviors>
    <Behaviors:MouseDragElementBehavior/>
  </Behaviors:Interaction.Behaviors>
</Rectangle>