Mouse Mouse Mouse Mouse Class

Definition

Represents the mouse device to a specific thread.

public ref class Mouse abstract sealed
public static class Mouse
type Mouse = class
Public Class Mouse
Inheritance
MouseMouseMouseMouse

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 GotMouseCaptureEvent GotMouseCaptureEvent GotMouseCaptureEvent

Identifies the GotMouseCapture attached event.

LostMouseCaptureEvent LostMouseCaptureEvent LostMouseCaptureEvent LostMouseCaptureEvent

Identifies the LostMouseCapture attached event.

MouseDownEvent MouseDownEvent MouseDownEvent MouseDownEvent

Identifies the MouseDown attached event.

MouseEnterEvent MouseEnterEvent MouseEnterEvent MouseEnterEvent

Identifies the MouseEnter attached event.

MouseLeaveEvent MouseLeaveEvent MouseLeaveEvent MouseLeaveEvent

Identifies the MouseLeave attached event.

MouseMoveEvent MouseMoveEvent MouseMoveEvent MouseMoveEvent

Identifies the MouseMove attached event.

MouseUpEvent MouseUpEvent MouseUpEvent MouseUpEvent

Identifies the MouseUp attached event.

MouseWheelDeltaForOneLine MouseWheelDeltaForOneLine MouseWheelDeltaForOneLine MouseWheelDeltaForOneLine

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

MouseWheelEvent MouseWheelEvent MouseWheelEvent MouseWheelEvent

Identifies the MouseWheel attached event.

PreviewMouseDownEvent PreviewMouseDownEvent PreviewMouseDownEvent PreviewMouseDownEvent

Identifies the PreviewMouseDown attached event.

PreviewMouseDownOutsideCapturedElementEvent PreviewMouseDownOutsideCapturedElementEvent PreviewMouseDownOutsideCapturedElementEvent PreviewMouseDownOutsideCapturedElementEvent

Identifies the PreviewMouseDownOutsideCapturedElement attached event.

PreviewMouseMoveEvent PreviewMouseMoveEvent PreviewMouseMoveEvent PreviewMouseMoveEvent

Identifies the PreviewMouseMove attached event.

PreviewMouseUpEvent PreviewMouseUpEvent PreviewMouseUpEvent PreviewMouseUpEvent

Identifies the PreviewMouseUp attached event.

PreviewMouseUpOutsideCapturedElementEvent PreviewMouseUpOutsideCapturedElementEvent PreviewMouseUpOutsideCapturedElementEvent PreviewMouseUpOutsideCapturedElementEvent

Identifies the PreviewMouseUpOutsideCapturedElement attached event.

PreviewMouseWheelEvent PreviewMouseWheelEvent PreviewMouseWheelEvent PreviewMouseWheelEvent

Identifies the PreviewMouseWheel attached event.

QueryCursorEvent QueryCursorEvent QueryCursorEvent QueryCursorEvent

Identifies the QueryCursor attached event.

Properties

Captured Captured Captured Captured

Gets the element that has captured the mouse.

DirectlyOver DirectlyOver DirectlyOver DirectlyOver

Gets the element the mouse pointer is directly over.

LeftButton LeftButton LeftButton LeftButton

Gets the state of the left button of the mouse.

MiddleButton MiddleButton MiddleButton MiddleButton

Gets the state of the middle button of the mouse.

OverrideCursor OverrideCursor OverrideCursor OverrideCursor

Gets or sets the cursor for the entire application.

PrimaryDevice PrimaryDevice PrimaryDevice PrimaryDevice

Gets the primary mouse device.

RightButton RightButton RightButton RightButton

Gets the state of the right button.

XButton1 XButton1 XButton1 XButton1

Gets the state of the first extended button.

XButton2 XButton2 XButton2 XButton2

Gets the state of the second extended button.

Methods

AddGotMouseCaptureHandler(DependencyObject, MouseEventHandler) AddGotMouseCaptureHandler(DependencyObject, MouseEventHandler) AddGotMouseCaptureHandler(DependencyObject, MouseEventHandler) AddGotMouseCaptureHandler(DependencyObject, MouseEventHandler)

Adds a handler for the GotMouseCapture attached event.

AddLostMouseCaptureHandler(DependencyObject, MouseEventHandler) AddLostMouseCaptureHandler(DependencyObject, MouseEventHandler) AddLostMouseCaptureHandler(DependencyObject, MouseEventHandler) AddLostMouseCaptureHandler(DependencyObject, MouseEventHandler)

Adds a handler for the LostMouseCapture attached event.

AddMouseDownHandler(DependencyObject, MouseButtonEventHandler) AddMouseDownHandler(DependencyObject, MouseButtonEventHandler) AddMouseDownHandler(DependencyObject, MouseButtonEventHandler) AddMouseDownHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the MouseDown attached event.

AddMouseEnterHandler(DependencyObject, MouseEventHandler) AddMouseEnterHandler(DependencyObject, MouseEventHandler) AddMouseEnterHandler(DependencyObject, MouseEventHandler) AddMouseEnterHandler(DependencyObject, MouseEventHandler)

Adds a handler for the MouseEnter attached event.

AddMouseLeaveHandler(DependencyObject, MouseEventHandler) AddMouseLeaveHandler(DependencyObject, MouseEventHandler) AddMouseLeaveHandler(DependencyObject, MouseEventHandler) AddMouseLeaveHandler(DependencyObject, MouseEventHandler)

Adds a handler for the MouseLeave attached event.

AddMouseMoveHandler(DependencyObject, MouseEventHandler) AddMouseMoveHandler(DependencyObject, MouseEventHandler) AddMouseMoveHandler(DependencyObject, MouseEventHandler) AddMouseMoveHandler(DependencyObject, MouseEventHandler)

Adds a handler for the MouseMove attached event.

AddMouseUpHandler(DependencyObject, MouseButtonEventHandler) AddMouseUpHandler(DependencyObject, MouseButtonEventHandler) AddMouseUpHandler(DependencyObject, MouseButtonEventHandler) AddMouseUpHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the MouseUp attached event.

AddMouseWheelHandler(DependencyObject, MouseWheelEventHandler) AddMouseWheelHandler(DependencyObject, MouseWheelEventHandler) AddMouseWheelHandler(DependencyObject, MouseWheelEventHandler) AddMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

Adds a handler for the MouseWheel attached event.

AddPreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the PreviewMouseDown attached event.

AddPreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the PreviewMouseDownOutsideCapturedElement attached event.

AddPreviewMouseMoveHandler(DependencyObject, MouseEventHandler) AddPreviewMouseMoveHandler(DependencyObject, MouseEventHandler) AddPreviewMouseMoveHandler(DependencyObject, MouseEventHandler) AddPreviewMouseMoveHandler(DependencyObject, MouseEventHandler)

Adds a handler for the PreviewMouseMove attached event.

AddPreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the PreviewMouseUp attached event.

AddPreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) AddPreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

Adds a handler for the PreviewMouseUpOutsideCapturedElement attached event.

AddPreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler) AddPreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler) AddPreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler) AddPreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

Adds a handler for the PreviewMouseWheel attached event.

AddQueryCursorHandler(DependencyObject, QueryCursorEventHandler) AddQueryCursorHandler(DependencyObject, QueryCursorEventHandler) AddQueryCursorHandler(DependencyObject, QueryCursorEventHandler) AddQueryCursorHandler(DependencyObject, QueryCursorEventHandler)

Adds a handler for the QueryCursor attached event.

Capture(IInputElement) Capture(IInputElement) Capture(IInputElement) Capture(IInputElement)

Captures mouse input to the specified element.

Capture(IInputElement, CaptureMode) Capture(IInputElement, CaptureMode) Capture(IInputElement, CaptureMode) Capture(IInputElement, CaptureMode)

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

GetIntermediatePoints(IInputElement, Point[]) GetIntermediatePoints(IInputElement, Point[]) GetIntermediatePoints(IInputElement, Point[]) GetIntermediatePoints(IInputElement, Point[])

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

GetPosition(IInputElement) GetPosition(IInputElement) GetPosition(IInputElement) GetPosition(IInputElement)

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

RemoveGotMouseCaptureHandler(DependencyObject, MouseEventHandler) RemoveGotMouseCaptureHandler(DependencyObject, MouseEventHandler) RemoveGotMouseCaptureHandler(DependencyObject, MouseEventHandler) RemoveGotMouseCaptureHandler(DependencyObject, MouseEventHandler)

Removes a handler for the GotMouseCapture attached event.

RemoveLostMouseCaptureHandler(DependencyObject, MouseEventHandler) RemoveLostMouseCaptureHandler(DependencyObject, MouseEventHandler) RemoveLostMouseCaptureHandler(DependencyObject, MouseEventHandler) RemoveLostMouseCaptureHandler(DependencyObject, MouseEventHandler)

Removes a handler for the LostMouseCapture attached event.

RemoveMouseDownHandler(DependencyObject, MouseButtonEventHandler) RemoveMouseDownHandler(DependencyObject, MouseButtonEventHandler) RemoveMouseDownHandler(DependencyObject, MouseButtonEventHandler) RemoveMouseDownHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the MouseDown attached event.

RemoveMouseEnterHandler(DependencyObject, MouseEventHandler) RemoveMouseEnterHandler(DependencyObject, MouseEventHandler) RemoveMouseEnterHandler(DependencyObject, MouseEventHandler) RemoveMouseEnterHandler(DependencyObject, MouseEventHandler)

Removes a handler for the MouseEnter attached event.

RemoveMouseLeaveHandler(DependencyObject, MouseEventHandler) RemoveMouseLeaveHandler(DependencyObject, MouseEventHandler) RemoveMouseLeaveHandler(DependencyObject, MouseEventHandler) RemoveMouseLeaveHandler(DependencyObject, MouseEventHandler)

Removes a handler for the MouseLeave attached event.

RemoveMouseMoveHandler(DependencyObject, MouseEventHandler) RemoveMouseMoveHandler(DependencyObject, MouseEventHandler) RemoveMouseMoveHandler(DependencyObject, MouseEventHandler) RemoveMouseMoveHandler(DependencyObject, MouseEventHandler)

Removes a handler for the MouseMove attached event.

RemoveMouseUpHandler(DependencyObject, MouseButtonEventHandler) RemoveMouseUpHandler(DependencyObject, MouseButtonEventHandler) RemoveMouseUpHandler(DependencyObject, MouseButtonEventHandler) RemoveMouseUpHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the MouseUp attached event.

RemoveMouseWheelHandler(DependencyObject, MouseWheelEventHandler) RemoveMouseWheelHandler(DependencyObject, MouseWheelEventHandler) RemoveMouseWheelHandler(DependencyObject, MouseWheelEventHandler) RemoveMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

Removes a handler for the MouseWheel attached event.

RemovePreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the PreviewMouseDown attached event.

RemovePreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the PreviewMouseDownOutsideCapturedElement attached event.

RemovePreviewMouseMoveHandler(DependencyObject, MouseEventHandler) RemovePreviewMouseMoveHandler(DependencyObject, MouseEventHandler) RemovePreviewMouseMoveHandler(DependencyObject, MouseEventHandler) RemovePreviewMouseMoveHandler(DependencyObject, MouseEventHandler)

Removes a handler for the PreviewMouseMove attached event.

RemovePreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the PreviewMouseUp attached event.

RemovePreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler) RemovePreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

Removes a handler for the PreviewMouseUpOutsideCapturedElement attached event.

RemovePreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler) RemovePreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler) RemovePreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler) RemovePreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

Removes a handler for the PreviewMouseWheel attached event.

RemoveQueryCursorHandler(DependencyObject, QueryCursorEventHandler) RemoveQueryCursorHandler(DependencyObject, QueryCursorEventHandler) RemoveQueryCursorHandler(DependencyObject, QueryCursorEventHandler) RemoveQueryCursorHandler(DependencyObject, QueryCursorEventHandler)

Removes a handler for the QueryCursor attached event.

SetCursor(Cursor) SetCursor(Cursor) SetCursor(Cursor) SetCursor(Cursor)

Sets the mouse pointer to the specified Cursor.

Synchronize() Synchronize() Synchronize() Synchronize()

Forces the mouse to resynchronize.

UpdateCursor() UpdateCursor() UpdateCursor() UpdateCursor()

Forces the mouse cursor to be updated.

Attached Events

GotMouseCapture GotMouseCapture GotMouseCapture GotMouseCapture

Occurs when an element captures the mouse.

LostMouseCapture LostMouseCapture LostMouseCapture LostMouseCapture

Occurs when an element loses mouse capture.

MouseDown MouseDown MouseDown MouseDown

Occurs when any mouse button is depressed.

MouseEnter MouseEnter MouseEnter MouseEnter

Occurs when the mouse pointer enters the boundaries of an element.

MouseLeave MouseLeave MouseLeave MouseLeave

Occurs when the mouse pointer leaves the boundaries of an element.

MouseMove MouseMove MouseMove MouseMove

Occurs when the mouse pointer moves.

MouseUp MouseUp MouseUp MouseUp

Occurs when any mouse button is released.

MouseWheel MouseWheel MouseWheel MouseWheel

Occurs when the mouse wheel is rotated.

PreviewMouseDown PreviewMouseDown PreviewMouseDown PreviewMouseDown

Occurs when any mouse button is depressed.

PreviewMouseDownOutsideCapturedElement PreviewMouseDownOutsideCapturedElement PreviewMouseDownOutsideCapturedElement PreviewMouseDownOutsideCapturedElement

Occurs when the primary mouse button is pressed outside the element that is capturing mouse events.

PreviewMouseMove PreviewMouseMove PreviewMouseMove PreviewMouseMove

Occurs when the mouse moves over an element.

PreviewMouseUp PreviewMouseUp PreviewMouseUp PreviewMouseUp

Occurs when any mouse button is released.

PreviewMouseUpOutsideCapturedElement PreviewMouseUpOutsideCapturedElement PreviewMouseUpOutsideCapturedElement PreviewMouseUpOutsideCapturedElement

Occurs when the primary mouse button is released outside the element that is capturing mouse events.

PreviewMouseWheel PreviewMouseWheel PreviewMouseWheel PreviewMouseWheel

Occurs when the mouse wheel rotates.

QueryCursor QueryCursor QueryCursor QueryCursor

Occurs when an element queries for the current mouse cursor.

Applies to