views:

2244

answers:

2

I was kind of expecting my ScrollViewer's child controls to hand the MouseWheel events back up the the ScrollViewer automatically, and that's not the case.

I have a ScrollViewer with a ListBox in it. If I manually resize the width of the ListBox to be less than the ScrollViewer, the MouseWheel works on all of the ScrollViewer but has no effect when the mouse is positioned above the ListBox.

What's the standard way to do this? Do I put an event trigger on the ListBox that fires the event on the parent? Do I handle and reroute the event in the code behind?

+6  A: 

The ListBox's template has a ScrollViewer in it, so that ScrollViewer will be handling the events and stopping them from propagating up the visual tree.

What exactly are you trying to achieve by having a ListBox inside a ScrollViewer? Perhaps you need to re-template the ListBox, but it's impossible to say without further info.

HTH, Kent

Kent Boogaart
I had no idea that the ScrollViewer was part of the ListBox's template, so I was under the assumption that I had to put the ListBox inside of a ScrollViewer. Thanks.
Rich
A: 

Say I want to scroll to a certain position in the list? I know you can scroll to a certain object using ListView.ScrollIntoView, but what if the list has 1000 objects and the first and last are actually the same object? The list only scrolls to the first row that is bound to that object. I can't find a way to scroll to a specified row without enclosing the ListView in a ScrollViewer, but then the ListView captures the mousewheel and arrow keys even though it doesn't display a scroll bar...