To attach a Routed Event handler for the MouseWheel event on a ScrollViewer you need to add the following code in the constructor of your Silverlight Page:
Additionaly, you will have to declare the OnMouseWheelHandler method:
Unfortunately, the method above is not suitable for enhancing controls which have internal ScrollViewer, such as the standard ListBox, because you cannot get a reference to its ScrollViewer, in order to attach the Routed Event handler. In this case you could create a Class Handler for the ScrollViewer type:
In this case, since it will affect ALL ScrollViewer controls on the page, the OnMouseWheelHandler method should be slightly different in order to avoid interference with the Telerik controls, which already have mouse wheel support:
The check could be modified to exclude certain controls, e.g. if you have only a couple of Telerik controls on your page and lots ot other controls, containing ScrollViwers, you could disable the handler only for the Telerik controls and enhance all other ScrollViwers on the page.
The IsAncestorOf method is an extension method, that you could declare in some static class in your application as:
Of course, the MouseWheel event is not limited to just scrolling ScrollViewer controls. For example, RadSlider and RadNumericUpDown use the MouseWheel event to change their values, you could zoom-in/out a DeepZoom image, etc. The possibilities are endless.
Attached is the source, containing the refactored code from the above. Happly MouseWheeling :)
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.