Method EnableDragMove
EnableDragMove()
Enables the ability to drag the current window using the mouse.
Declaration
IDisposable EnableDragMove()
Returns
Type | Description |
---|---|
IDisposable | An IDisposable instance that can be used to programmatically stop the dragging operation. Disposing this object will immediately stop the drag operation and release mouse capture. |
Remarks
- When this method is called, the window captures the mouse input.
- As the mouse moves, the window's position updates, effectively dragging the window.
- The drag operation stops when:
- The left mouse button is released.
- The returned IDisposable is disposed.
This method is useful for implementing custom window dragging behavior, such as for frameless windows or custom title bars that do not use the default window drag functionality.
Examples
Example usage:
var dragDisposable = window.EnableDragMove();
// Dragging will continue until:
// 1. The left mouse button is released.
// 2. dragDisposable.Dispose() is called.