Window.DragMove Method

Definition

Allows a window to be dragged by a mouse with its left button down over an exposed area of the window's client area.

C#
[System.Security.SecurityCritical]
public void DragMove();
C#
public void DragMove();
Attributes

Exceptions

The left mouse button is not down.

Examples

The following example shows how to override OnMouseLeftButtonDown to call DragMove.

C#
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
    base.OnMouseLeftButtonDown(e);

    // Begin dragging the window
    this.DragMove();
}

Remarks

The left mouse button must be down when DragMove is called. One way to detect when the left mouse button is pressed is to handle the MouseLeftButtonDown event.

When DragMove is called, the left mouse button must be depressed over an exposed area of the window's client area.

Note

This method cannot be called when a window is hosted in a browser.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also