Mouse Class

Definition

Represents the mouse device to a specific thread.

public static class Mouse
Inheritance
Mouse

Remarks

The Mouse class provides mouse related events, methods and, properties which provide information regarding the state of the mouse.

Each event that Mouse defines as an attached event is also re-exposed by the base element classes UIElement and ContentElement as a new routed event. Generally, it is more convenient to handle mouse events for an application on UIElement and ContentElement, rather than using the Mouse events. For details, see Input Overview.

The static members of the Mouse class delegate to the primary MouseDevice of the calling thread's input manager.

Fields

GotMouseCaptureEvent

Identifies the GotMouseCapture attached event.

LostMouseCaptureEvent

Identifies the LostMouseCapture attached event.

MouseDownEvent

Identifies the MouseDown attached event.

MouseEnterEvent

Identifies the MouseEnter attached event.

MouseLeaveEvent

Identifies the MouseLeave attached event.

MouseMoveEvent

Identifies the MouseMove attached event.

MouseUpEvent

Identifies the MouseUp attached event.

MouseWheelDeltaForOneLine

Represents the number of units the mouse wheel is rotated to scroll one line.

MouseWheelEvent

Identifies the MouseWheel attached event.

PreviewMouseDownEvent

Identifies the PreviewMouseDown attached event.

PreviewMouseDownOutsideCapturedElementEvent

Identifies the PreviewMouseDownOutsideCapturedElement attached event.

PreviewMouseMoveEvent

Identifies the PreviewMouseMove attached event.

PreviewMouseUpEvent

Identifies the PreviewMouseUp attached event.

PreviewMouseUpOutsideCapturedElementEvent

Identifies the PreviewMouseUpOutsideCapturedElement attached event.

PreviewMouseWheelEvent

Identifies the PreviewMouseWheel attached event.

QueryCursorEvent

Identifies the QueryCursor attached event.

Properties

Captured

Gets the element that has captured the mouse.

DirectlyOver

Gets the element the mouse pointer is directly over.

LeftButton

Gets the state of the left button of the mouse.

MiddleButton

Gets the state of the middle button of the mouse.

OverrideCursor

Gets or sets the cursor for the entire application.

PrimaryDevice

Gets the primary mouse device.

RightButton

Gets the state of the right button.

XButton1

Gets the state of the first extended button.

XButton2

Gets the state of the second extended button.

Methods

AddGotMouseCaptureHandler(DependencyObject, MouseEventHandler)

Adds a handler for the GotMouseCapture attached event.

AddLostMouseCaptureHandler(DependencyObject, MouseEventHandler)

Adds a handler for the LostMouseCapture attached event.

AddMouseDownHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the MouseDown attached event.

AddMouseEnterHandler(DependencyObject, MouseEventHandler)

Adds a handler for the MouseEnter attached event.

AddMouseLeaveHandler(DependencyObject, MouseEventHandler)

Adds a handler for the MouseLeave attached event.

AddMouseMoveHandler(DependencyObject, MouseEventHandler)

Adds a handler for the MouseMove attached event.

AddMouseUpHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the MouseUp attached event.

AddMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

Adds a handler for the MouseWheel attached event.

AddPreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the PreviewMouseDown attached event.

AddPreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the PreviewMouseDownOutsideCapturedElement attached event.

AddPreviewMouseMoveHandler(DependencyObject, MouseEventHandler)

Adds a handler for the PreviewMouseMove attached event.

AddPreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the PreviewMouseUp attached event.

AddPreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the PreviewMouseUpOutsideCapturedElement attached event.

AddPreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

Adds a handler for the PreviewMouseWheel attached event.

AddQueryCursorHandler(DependencyObject, QueryCursorEventHandler)

Adds a handler for the QueryCursor attached event.

Capture(IInputElement)

Captures mouse input to the specified element.

Capture(IInputElement, CaptureMode)

Captures mouse input to the specified element using the specified CaptureMode.

Equals(Object) Inherited from Object
Equals(Object, Object) Inherited from Object
GetHashCode() Inherited from Object
GetIntermediatePoints(IInputElement, Point[])

Retrieves up to 64 previous coordinates of the mouse pointer since the last mouse move event.

GetPosition(IInputElement)

Gets the position of the mouse relative to a specified element.

GetType() Inherited from Object
MemberwiseClone() Inherited from Object
ReferenceEquals(Object, Object) Inherited from Object
RemoveGotMouseCaptureHandler(DependencyObject, MouseEventHandler)

Removes a handler for the GotMouseCapture attached event.

RemoveLostMouseCaptureHandler(DependencyObject, MouseEventHandler)

Removes a handler for the LostMouseCapture attached event.

RemoveMouseDownHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the MouseDown attached event.

RemoveMouseEnterHandler(DependencyObject, MouseEventHandler)

Removes a handler for the MouseEnter attached event.

RemoveMouseLeaveHandler(DependencyObject, MouseEventHandler)

Removes a handler for the MouseLeave attached event.

RemoveMouseMoveHandler(DependencyObject, MouseEventHandler)

Removes a handler for the MouseMove attached event.

RemoveMouseUpHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the MouseUp attached event.

RemoveMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

Removes a handler for the MouseWheel attached event.

RemovePreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the PreviewMouseDown attached event.

RemovePreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the PreviewMouseDownOutsideCapturedElement attached event.

RemovePreviewMouseMoveHandler(DependencyObject, MouseEventHandler)

Removes a handler for the PreviewMouseMove attached event.

RemovePreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the PreviewMouseUp attached event.

RemovePreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the PreviewMouseUpOutsideCapturedElement attached event.

RemovePreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

Removes a handler for the PreviewMouseWheel attached event.

RemoveQueryCursorHandler(DependencyObject, QueryCursorEventHandler)

Removes a handler for the QueryCursor attached event.

SetCursor(Cursor)

Sets the mouse pointer to the specified Cursor.

Synchronize()

Forces the mouse to resynchronize.

ToString() Inherited from Object
UpdateCursor()

Forces the mouse cursor to be updated.

Applies to