Open aquinn39 opened 2 years ago
This seems to be the issue causing this: https://github.com/dotnet/wpf/issues/3545
Some code that can be used on the PreviewMouseWheel event of a ScrollViewer to enable a smoother scrolling experience, not sure if there's a better way to do this:
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
// Try catches here just to ensure app does not crash and instead falls back to default WPF scrolling behaviour if an exception occurs here for whatever reason
try
{
// Disables custom scroll handling when scroll by one screen at a time is enabled in mouse settings. Feel free to handle this yourself if you wish.
if (System.Windows.Forms.SystemInformation.MouseWheelScrollLines == -1)
e.Handled = false;
else
try
{
// Scrolls the scroll viewer according to the delta value and the user's scrolling settings
System.Windows.Controls.ScrollViewer SenderScrollViewer = (System.Windows.Controls.ScrollViewer)sender;
SenderScrollViewer.ScrollToVerticalOffset(SenderScrollViewer.VerticalOffset - e.Delta * 10 * System.Windows.Forms.SystemInformation.MouseWheelScrollLines / (double)120);
e.Handled = true;
}
catch
{
}
}
catch
{
}
}
I would very much like to have this implemented. Scrolling on Windows Precision touch pads (i.e. on practically every laptop on the market for the past couple years) is currently pretty much unusable on WPF.
Over a year later and this is still a major issue on basically all laptops :(
At the moment, the WPF ScrollViewer always scrolls a fixed amount in response to mouse wheel events despite MouseWheelEventArgs returning the Delta value (The value that Windows sends as part of mouse wheel scrolling messages that determines how fast content should scroll.) Because of this, scrolling with precision scrolling devices such as touchpads scrolls ridiculously fast, making scrolling with devices like touchpads pretty much useless. If the ScrollViewer could respond properly to the MouseWheelEventArgs.Delta value (i.e. scroll an appropriate amount depending on the delta value, which is just an integer), this would make scrolling in WPF so much better and greatly improve the user experience.