sbaeumlisberger / VirtualizingWrapPanel

Implementation of a comprehensive VirtualisingWrapPanel for WPF
MIT License
254 stars 35 forks source link

Mouse Wheel Scrolling by Item does not always work #12

Closed MikeWilliams-UK closed 3 years ago

MikeWilliams-UK commented 3 years ago

Describe your issue I have set VirtualizingStackPanel.ScrollUnit="Item"

However scrolling with mouse wheel does not scroll by Item when ItemSize is set. Scrolling by clicking on the arrows of the scroll bar works as expected. It's reproducable in Tab2 of your examples.

image

Version Info Package Version 1.5.3 .NET Version: 4.8 OS Version: Windows 10 1903 build 18362.1139

sbaeumlisberger commented 3 years ago

Hi,

that's the expected behaviour. When using the mouse wheel the VirtualizingWrapPanel scrolls 3 items by default. But it never scrolls more than the viewport, therefore it may looks like it does not scroll itemwise.

You can change the number of items scrolled by mouse wheel by setting the the property MouseWheelDeltaItem to an integer value.

MikeWilliams-UK commented 3 years ago

If that's so why does it scroll by a whole item when you click on the arrows.

sbaeumlisberger commented 3 years ago

That's because the implementation handling the scrollbar arrows does not use the property and scrolls fixed one item.

sbaeumlisberger commented 3 years ago

This difference also exists when scrolling by pixel. The mouse wheel scrolls 48 pixels and the arrows 16 pixels. This are the default values also used by other WPF controls.

MikeWilliams-UK commented 3 years ago

I shall try setting MouseWheelDeltaItem to 1 to see if it fixes our issue

sbaeumlisberger commented 3 years ago

Right, let me know if that solves your issue.

MikeWilliams-UK commented 3 years ago

Thanks, setting MouseWheelDeltaItem to 1 did the trick.