Microsoft Silverlight will reach end of support after October 2021. Learn more.
Assembly: System.Windows (in System.Windows.dll)
'Declaration Public Event MouseWheel As MouseWheelEventHandler
public event MouseWheelEventHandler MouseWheel
The MouseWheel event is a bubbling event. This means that if multiple MouseWheel event handlers are registered for a sequence of objects connected by parent-child relationships in the object tree, the event is potentially received by each object in that relationship. The bubbling metaphor indicates that the event starts at the source and works its way up the object tree. For a bubbling event, the sender available to the event handler identifies the object where the event is handled, not necessarily the object that actually received the input condition that initiated the event. To get the object that initiated the event, use the OriginalSource value of the event data.
Handling mouse wheel events may require techniques beyond just handling this event, depending on your application and platform considerations. For more information, see Mouse Wheel Input.
If a UIElement has mouse capture, it can generate MouseWheel events even if the pointer has moved elsewhere.
MouseWheel and OnMouseWheel
Controls that inherit MouseWheel can provide handling for the event that acts as handler for all instances, by overriding the OnMouseWheel method. This might include marking the Handled value of the event as true, which has the effect of suppressing further handling of the MouseWheel event on any instance of the control (and potentially any subclass of the control.
You can also register handlers such that they are invoked even for already-handled routed events. For more information, see AddHandler.
Silverlight 4 has controls that have specific control handling for MouseWheel, which means that in certain cases your user code event handlers are not invoked, because the control marks the event as handled. You can still handle these cases, but you must specifically attach the handler with AddHandler and handledEventsToo as true. This cannot be enabled in XAML. Consult specific control documentation to see if that control implements OnMouseWheel, which is often an indicator of control-level handling.
If you are targeting Silverlight 3, it is less likely that control-level handling exists, and thus you should not need AddHandler to register handlers. However, this also means that certain UI actions for Silverlight 3 controls might not have built-in support for a mouse wheel action, and you might instead have to implement that support in user code.
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.