I hope someone have a hint/solution to solve this problem in a better and more performant way.
I'm writting an Windows UWP app with contains a ScrollViewer with a grid. In this grid I have two StackPanels embedded in a ScrollViewer.
Each StackPanel has a list of images in a vertical orientation. The StackPanel is as height as all images are together so there is no vertical scrollbar as it should be. On the other hand the images are wider then the StackPanel and the horizontal scrollbar is shown. I can scroll the StackPanels in the horizontal direction with the mouse. This works perfectly.
But if I'm over a StackPanel with the mouse I can not scroll the surrounding ScrollViewer with the mouse wheel in the vertical direction. The ScrollViewer around the StackPanels will consume the MouseWheel events and will not bubbling it up to the parent ScrollViewer.
Does someone know how I can bubbling up/redirect the MouseWheel event to the parent ScrollViewer?
I've found a not so good workaround for this. I've added an own UIElement.PointerWheelChangedEvent handler and move the outer ScrollViewer on my own, like this:
LeftScrollViewer.AddHandler(UIElement.PointerWheelChangedEvent, new PointerEventHandler(OnVerticalScrollEventHandled), true);
private void OnVerticalScrollEventHandled(object sender, PointerRoutedEventArgs e)
{
ScrollViewPages.ChangeView(ScrollViewPages.HorizontalOffset, ScrollViewPages.VerticalOffset + (-1 * e.GetCurrentPoint(null).Properties.MouseWheelDelta), 1);
}
This works but not in a fast and fluid way. Has someone a better solution?
ScrollViewer
, it doesn't scroll? Does it scroll when you hover over an image? – Laith