Returns the x- and y-coordinates of the mouse pointer position, optionally evaluated against a coordinate origin of a supplied UIElement.
Assembly: System.Windows (in System.Windows.dll)
Return ValueType: System.Windows.Point
A Point that represents the current x- and y-coordinates of the mouse pointer position. If null was passed as relativeTo, this coordinate is for the overall Silverlight plug-in content area. If a non-null relativeTo was passed, this coordinate is relative to the object referenced by relativeTo.
The most common usage is to pass relativeTo as Nothing, which returns a coordinate position of the mouse within the overall Silverlight plug-in content area.
The relativeTo parameter can also be set to any UIElement-derived object that is contained by the Silverlight plug-in. The returned mouse pointer position is relative to the object referenced as relativeTo. Depending on the location of relativeTo relative to the object, the coordinate values of the mouse position may be negative values.
If you are handling the event from the root element of the visual tree and FlowDirection equals LeftToRight, passing the root element as relativeTo or passing Nothing are equivalent.
The UIElement that is passed as relativeTo must be connected to the current object hierarchy, in such a way that successive resolution of parents is connected to the root element. Passing a UIElement that is disconnected will generate an error.
Because some mouse events bubble, the sender parameter of the event handler that also received the event data may or may not be suitable for use as a frame of reference for the relativeTo parameter of . Make sure that your handler for a mouse event that attempts to use sender for a call is being handled by the expected object, and has not bubbled upwards, perhaps being handled by the root element if you also have a handler there.
If the Windowless property is true for the Silverlight plug-in, Silverlight can only provide information about the mouse while the mouse pointer is over the Silverlight plug-in's content area . If Windowless is true, a captured mouse will continue to update its position even when the pointer is no longer over the area that raised the mouse event, but will cease updating position (and lose capture) if the pointer exits the Silverlight plug-in content area entirely (moves to a different area of the hosting HTML page, or off the browser window entirely and onto the desktop). If Windowless is false, a captured mouse will continue to update its position when the pointer exits the Silverlight plug-in content area or the browser window that hosts the plug-in.
The position returned by is not the position of the client user's overall screen, or even of the hosting browser, it is purely a coordinate space used by Silverlight in its content area. Depending on what information a given browser exposes to its DOM, it is often possible to obtain a browser positional offset for the Silverlight content area from the HTML DOM, and add that offset to the X and Y values from the Silverlight mouse position to get a browser-relative coordinate. This might be useful if you are working with HTML overlays.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.