xxxxxxxxxx
Private Sub ScrollViewer_PreviewMouseWheel(sender As Object, e As MouseWheelEventArgs)
' 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 Then
e.Handled = False
Else
Try
' Scrolls the scroll viewer according to the delta value and the user's scrolling settings
Dim SenderScrollViewer As System.Windows.Controls.ScrollViewer = sender
SenderScrollViewer.ScrollToVerticalOffset(SenderScrollViewer.VerticalOffset - e.Delta * 10 * System.Windows.Forms.SystemInformation.MouseWheelScrollLines / 120)
e.Handled = True
Catch
End Try
End If
Catch
End Try
End Sub
xxxxxxxxxx
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
{
}
}