Hello,
Can you tell me if there is a way to enable horizontal scrolling with the scroll wheel in the PDF viewer?
This is the same in acrobat, when not holding down the shift key the scroll wheel scrolls the document vertically. When holding down the shift key it scrolls horizontally.
Thanks!
For anyone who wants this functionality:
I added 2 variables in the code behind:
private double _horizontalOffset;
private double _verticalOffset;In the xaml I've added 2 event handlers to the PreviewMouseWheel and ScrollChanged events:
<PdfViewer:PdfViewerControl Name="PdfViewerControl" PreviewMouseWheel="PdfViewerControl_PreviewMouseWheel" ScrollChanged="PdfViewerControl_ScrollChanged" />
The code behind for these events look like:
private void PdfViewerControl_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (Keyboard.Modifiers == ModifierKeys.Shift)
{
var zoomFactor = PdfViewerControl.ZoomPercentage / 100d;
PdfViewerControl.ScrollTo((_horizontalOffset + -e.Delta) / zoomFactor, _verticalOffset / zoomFactor);
e.Handled = true;
}
}
private void PdfViewerControl_ScrollChanged(object sender, ScrollChangedEventArgs args)
{
_horizontalOffset = args.HorizontalOffset;
_verticalOffset = args.VerticalOffset;
}