Export (0) Print
Expand All

Window.DragMove Method

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

Namespace: System.Windows
Assembly: PresentationFramework (in presentationframework.dll)

public void DragMove ()
public void DragMove ()
public function DragMove ()
You cannot use methods in XAML.

Exception typeCondition

InvalidOperationException

The left mouse button is not down.

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 rectangle.

NoteNote:

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

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

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

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft