Class MouseDragElementBehavior
Repositions the attached element in response to mouse drag gestures on the element.
public class MouseDragElementBehavior : Behavior<FrameworkElement>, IAnimatable, IAttachedObject
- Inheritance
-
MouseDragElementBehavior
- Implements
- Derived
- Inherited Members
- Extension Methods
Fields
ConstrainToParentBoundsProperty
Dependency property for the ConstrainToParentBounds property. If true, the dragged element will be constrained to stay within the bounds of its parent container.
public static readonly DependencyProperty ConstrainToParentBoundsProperty
Field Value
ParentElementProperty
public static readonly DependencyProperty ParentElementProperty
Field Value
XProperty
Dependency property for the X position of the dragged element, relative to the left of the root element.
public static readonly DependencyProperty XProperty
Field Value
YProperty
Dependency property for the Y position of the dragged element, relative to the top of the root element.
public static readonly DependencyProperty YProperty
Field Value
Properties
ConstrainToParentBounds
Gets or sets a value indicating whether the dragged element is constrained to stay within the bounds of its parent container. This is a dependency property.
public bool ConstrainToParentBounds { get; set; }
Property Value
- bool
True
if the dragged element should be constrained to its parents bounds; otherwise,False
.
ParentElement
Gets the parent element of the associated object.
public FrameworkElement ParentElement { get; set; }
Property Value
- FrameworkElement
The parent element of the associated object.
X
Gets or sets the X position of the dragged element, relative to the left of the root element. This is a dependency property.
public double X { get; set; }
Property Value
Y
Gets or sets the Y position of the dragged element, relative to the top of the root element. This is a dependency property.
public double Y { get; set; }
Property Value
Methods
AfterDragging()
protected virtual void AfterDragging()
ApplyTranslationTransform(double, double)
Applies the given translation to the RenderTransform of the associated element.
protected virtual void ApplyTranslationTransform(double x, double y)
Parameters
x
doubleThe X component of the translation in parent coordinates.
y
doubleThe Y component of the translation in parent coordinates.
BeforeDragging()
protected virtual void BeforeDragging()
OnAttached()
Called after the behavior is attached to an AssociatedObject.
protected override void OnAttached()
Remarks
Override this to hook up functionality to the AssociatedObject.
OnDetaching()
Called when the behavior is getting detached from its AssociatedObject, but before it has actually occurred.
protected override void OnDetaching()
Remarks
Override this to unhook functionality from the AssociatedObject.
OnMouseLeftButtonDown(object, MouseButtonEventArgs)
protected void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
Parameters
sender
objecte
MouseButtonEventArgs
Events
DragBegun
Occurs when a drag gesture is initiated.
public event MouseEventHandler DragBegun
Event Type
DragFinished
Occurs when a drag gesture is finished.
public event MouseEventHandler DragFinished
Event Type
Dragging
Occurs when a drag gesture update is processed.
public event MouseEventHandler Dragging