Share via


Window.DragMove Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

In trusted applications, begins a mouse drag operation to move the window.

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Sub DragMove
[SecuritySafeCriticalAttribute]
public void DragMove()

Exceptions

Exception Condition
UnauthorizedAccessException

The current thread is not the user interface (UI) thread.

SecurityException

Application.HasElevatedPermissions is false.

Remarks

You typically use this method to implement a way for users to drag the window when you hide the window title bar. For information about hiding the title bar and border, see How to: Configure an Application for Out-of-Browser Support.

Examples

The following code example demonstrates the use of this method.

' Handle dragging the main window.
Private Sub UserControl_MouseLeftButtonDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
    If Application.Current.IsRunningOutOfBrowser Then
        Application.Current.MainWindow.DragMove()
    End If
End Sub
// Handle dragging the main window.
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    if (Application.Current.IsRunningOutOfBrowser)
    {
        Application.Current.MainWindow.DragMove();
    }
}

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.