Be careful when you write code for a MouseMove handler. The MouseMove event will frequently occur while the user is interacting with the application or with the specific object area that has the handler. Any computationally or graphically intensive code in a MouseMove handler can potentially introduce a noticeable lag in how the mouse pointer draws and how the application generally behaves.
The MouseMove event can be defined for any UIElement-derived class, such as Canvas, TextBlock, or Rectangle.
The MouseMove event is typically raised in response to the mouse pointer moving across the object's bounding area. If the mouse pointer enters the object's bounding area, the MouseEnter event precedes the MouseMove event for the object.
The MouseMove event is a bubbling event. This means that if multiple MouseMove events are defined for a tree of elements, the event is received by each object in the object hierarchy, starting with the object that directly receives the event, and then bubbling to each successive parent element. The bubbling metaphor indicates that the event starts at the bottom and works its way up the object tree. For a bubbling event, the sender parameter identifies the object where the event is handled, not necessarily the object that actually received the input condition that initiated the event.
For more information on basic concepts, see Mouse Support. Note that the Mouse Support topic is written primarily for users of the managed API, and may not have code examples or specific information that address the JavaScript API scenarios.
You can also add handlers in script by using a quoted string for the event handler name, as follows:
object.AddEventListener("MouseMove", "eventhandlerFunction")
This syntax also returns a token. However, the token is not an absolute requirement for removing the handler in cases where the handler was added by using a quoted string. For details, see RemoveEventListener.