PointerEventArgs
Base class for pointer-related events, including mouse events.Properties
Gets the specific pointer generated by the input device. Each mouse, touch contact, or pen has its own pointer ID.
Gets the time when the input occurred, in milliseconds.
Gets a value that indicates which key modifiers (Ctrl, Shift, Alt) were active when the pointer event was initiated.
Gets the state of the pointer device when this event occurred, including which buttons are pressed.
Methods
Gets the pointer position relative to a control.Pass
null to get the position in toplevel coordinates.Returns the PointerPoint associated with the current event, relative to the specified visual.
Returns intermediate pointer points that occurred between the last event and this one. Useful for smooth drawing or gesture recognition.
Prevents this event from being handled by gesture recognizers in the route.
PointerPressedEventArgs
Provides information for pointer pressed (mouse down) events.Properties
Gets the number of clicks (1 for single click, 2 for double click, etc.).
PointerReleasedEventArgs
Provides information for pointer released (mouse up) events.Properties
Gets the mouse button that triggered the corresponding PointerPressed event.
PointerWheelEventArgs
Provides information for mouse wheel events.Properties
Gets the mouse wheel delta.
Delta.Yrepresents vertical scrolling (positive = scroll up, negative = scroll down)Delta.Xrepresents horizontal scrolling (if supported)
MouseButton Enumeration
Defines mouse buttons:None- No buttonLeft- Left mouse buttonRight- Right mouse buttonMiddle- Middle mouse button (wheel click)XButton1- First extended buttonXButton2- Second extended button
PointerPointProperties
Describes the state of a pointer device.Properties
IsLeftButtonPressed- Gets whether the left button is pressedIsRightButtonPressed- Gets whether the right button is pressedIsMiddleButtonPressed- Gets whether the middle button is pressedIsXButton1Pressed- Gets whether the first extended button is pressedIsXButton2Pressed- Gets whether the second extended button is pressedPointerUpdateKind- Gets the type of pointer update (left/right/middle button down/up, etc.)
Usage Examples
Handling Mouse Click Events
Tracking Mouse Movement
Handling Mouse Wheel
Drawing with Mouse
Checking Modifier Keys
Best Practices
- Use Pointer Events: Prefer
PointerPressed,PointerMoved,PointerReleasedover legacy mouse events for better cross-platform support - Capture the Pointer: Use
e.Pointer.Capture(this)during drag operations to ensure you receive all events - Release Capture: Always release capture with
e.Pointer.Capture(null)when done - Mark Events as Handled: Set
e.Handled = trueto prevent event bubbling - Check PointerType: Use
e.Pointer.Typeto distinguish between mouse, touch, and pen input - Use Intermediate Points: For drawing or gesture recognition, use
GetIntermediatePoints()to avoid missing events