views:

39

answers:

2

Hey guys

I am trying to overwrite a event handler of MouseWheel for a ScrollViewer. Since ScrollViewer is sealed, I cant simply create a "custom" class inheriting it. I guess the generic question would be: "How do I overwrite the default event." (Or something like that ;-))

Edit: The event which should replace the default "scroll" only gets fired when the ScrollViewer can't be scrolled or reaches a limit.

A: 

In your event handler, set the Handled property of the MouseWheelEventArgs parameter to true before returning.

James Curran
Not working, the ScrollViewer still scrolls.
Dänu
+1  A: 

Since ScrollViewer is sealed it will be difficult to override its behavior. The ScrollChanged event only provides readonly information and can not be canceled. You might have to implement your own scroll viewer derived from ContentControl instead. What scroll behavior are you trying to implement?

Wallstreet Programmer
Well I wanted to create a "Drag to Scroll" - only ScrollViewer on which the user can zoom using the mousewheel, but I guess it's actually really easier to implement this without using a ScrollViewer at all.
Dänu