Export (0) Print
Expand All

MouseEventArgs Class

Provides data for mouse-related events that do not specifically involve mouse buttons, for example UIElement.MouseMove.

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

'Declaration
Public Class MouseEventArgs _
	Inherits RoutedEventArgs

The MouseEventArgs type exposes the following members.

  NameDescription
Public propertySupported by Silverlight for Windows PhoneOriginalSourceGets a reference to the object that raised the event. (Inherited from RoutedEventArgs.)
Public propertySupported by Silverlight for Windows PhoneStylusDeviceGets an object that reports stylus device information, such as the collection of stylus points associated with the input.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetPositionReturns the x- and y-coordinates of the mouse pointer position, optionally evaluated against a coordinate origin of a supplied UIElement.
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneToStringReturns a string that represents the current object. (Inherited from Object.)
Top

This event data class is used with the following mouse events.

Note that events that specifically deal with mouse button events use a different event data class, MouseButtonEventArgs. Events that deal with the mouse wheel use MouseWheelEventArgs. MouseButtonEventArgs and MouseWheelEventArgs both derive from MouseEventArgs. Therefore, you can use the shared API (MouseEventArgs.GetPosition or MouseEventArgs.StylusDevice) for any Silverlight mouse event through event handling and the event data.

In the WPF implementation of MouseEventArgs, you could check properties to determine mouse button state even if the event was not a button-related event, and also could query for the underlying device. Neither of these features are supported in the Silverlight 5 implementation of MouseEventArgs.

The most relevant member of MouseEventArgs is GetPosition, which is a method, not a property. Particularly for a mouse button event, or for cases where the mouse is captured, it is often useful to know the exact mouse pointer position at time of the event. GetPosition returns that position relative to the Silverlight coordinate space, or optionally against the specific coordinate space of a supplied reference element.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft