Skip to content

Have the ScrollViewer take into account the Delta value when responding to mousewheel events #5936

Open

Description

@aquinn39

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.

Activity

  1. added
    Enhancement Requested
    and removed on Jan 12, 2022
  2. added this to the Future milestone on Jan 12, 2022
  3. self-assigned this
    on Jan 12, 2022
  4. aquinn39 commented on Feb 15, 2023

    @aquinn39
    Author

    This seems to be the issue causing this: #3545

  5. aquinn39 commented on Feb 15, 2023

    @aquinn39
    Author

    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
    
            {
    
            }
            }
    
  6. DanielRouxSA commented on Sep 8, 2023

    @DanielRouxSA

    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.

  7. SVNKoch commented on Nov 3, 2024

    @SVNKoch

    Over a year later and this is still a major issue on basically all laptops :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement Requested

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions