Unable to scroll in horizontal ItemsView using mouse wheel
Describe the bug
When setting up a ItemsView with a StackLayout that has Orientation="Horizontal" set, I cannot scroll through the list using the mouse wheel. This was and is possible with ListView when using a ItemsStackPanel with Orientation="Horizontal"
Steps to reproduce the bug
<ItemsView>
<ItemsView.Layout>
<StackLayout Orientation="Horizontal" />
</ItemsView.Layout>
...
</ItemsView>
Expected behavior
I can scroll through the list using the mouse wheel
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.7.2: 1.7.250513003
Windows version
Windows 11 (24H2): Build 26100
Additional context
This bug report is likely related: https://github.com/dotnet/maui/issues/22680
Agreed, and the ItemsView/ScrollView does not expose any useful scroll control methods at all, making it almost impossible to simulate user scrolling or accelerate scrolling.
Hello @tipa, can you please add a minimal repro application here which contains both ListView & ItemsView in same window with highlighting the problem you are facing ItemsView? It would help in triaging the issue faster
@Hemantxk Sure - here's an example project: test.zip
@tipa Thanks for providing the sample.
There is an existing proposal for adding this functionality to scroll view: https://github.com/microsoft/microsoft-ui-xaml/issues/877
In the meantime, as a workaround, you can try hooking into the PointerWheelChanged event in your ItemsView_Loaded handler:
void ItemsView_Loaded(object sender, RoutedEventArgs e)
{
itemsView.ScrollView.HorizontalScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollingScrollBarVisibility.Hidden;
itemsView.ScrollView.VerticalScrollMode = Microsoft.UI.Xaml.Controls.ScrollingScrollMode.Disabled;
itemsView.ScrollView.HorizontalScrollMode = Microsoft.UI.Xaml.Controls.ScrollingScrollMode.Enabled;
//PointerWheelChanged event for horizontal scrolling
itemsView.ScrollView.PointerWheelChanged += (sender,e) =>
{
var delta = e.GetCurrentPoint(itemsView).Properties.MouseWheelDelta;
itemsView.ScrollView.ScrollTo(itemsView.ScrollView.HorizontalOffset - delta, itemsView.ScrollView.VerticalOffset);
};
}
This should help simulate horizontal scrolling behavior using the mouse wheel.
Thanks for your response and workaround @zinniaa. I think it can be simplified as follows:
void ItemsView_Loaded(object sender, RoutedEventArgs e)
{
var itemsView = sender as ItemsView;
itemsView.ScrollView.PointerWheelChanged += (sender, e) =>
{
var delta = e.GetCurrentPoint(itemsView).Properties.MouseWheelDelta;
itemsView.ScrollView.ScrollBy(-delta, 0, new ScrollingScrollOptions(ScrollingAnimationMode.Disabled));
};
}
Unfortunately, I had to use ScrollingAnimationMode.Disabled because when animating the scroll, the scrolling experience is completely unsatisfactory, especially when trying to fast-scroll - because each scrolling event seems to cancel out the previous one, the scroll view almost doesn't scroll at all as a result.
But using ScrollingAnimationMode.Disabled can't be a long-term solution either, user expect to have a smooth scrolling experience.
I am quite surprised that the linked feature proposal is over 6 years old, with many users asking for it, yet this is still not possible. It would be much appreciated if this could get some priority.