Scrolling speed of WPF viewer cOntrol

Hey,

i use the pdfnet .net 4.0 sdk in specially the wpf control. Is there a way to set up the scolling speed up of the control when the person use the mouswheel to scroll in the document.

Best regards

Daniel

PDFViewWPF is using a Windows WPF ScrollViewer, so to add your own custom scrolling logic, to take into account the Control Panel’s Vertical Scrolling setting in the Mouse Properties window, you need to do the following.

  1. Hide the built in scroll bars
  2. Add your own scroll bars and connect to PDFViewWPF.
  3. Query the System.Windows.Forms.SystemInformation.MouseWheelScrollLines to get the users current setting.
  4. Calculate new value to scroll by.

The following information will help you get started accomplishing the above.

The PDFViewWPF class has properties for HorizontalScrollBarVisibility and VerticalScrollBarVisibility.
Setting both of them to hidden will let you attach your own Scroller that is external. You can then make this touch enabled if you wish.

To help you with this, I have modifed PDFViewControl.xaml and PDFViewControl.xaml.cs so that a separate Scroller is used that syncs with the PDFViewWPF. I made it reddish in color, to make it more visible. I call it MyScrollBarOnTheSide. See attached.

The interesting parts of PDFViewControl.xaml.cs are at the bottom of the constructor, where I hide the PDFViewWPF’s vertical scrollbar, and register for the ValueChanged event of MyScrollBarOnTheSide. I then modified some of the event handlers for the PDFViewWPF, which you can find by searching for SyncScrollBarPosition and SyncScrollerFromViewer. Finally, there’s a region labelled ScrollbarSyncing at the bottom of the file.

This should give you a good framework to replace the scroller, which will let you add in your custom handling of the MouseWheelScrollLines user setting.

PDFViewControl.xaml.cs.txt (36.5 KB)

PDFViewControl.xaml.txt (1.66 KB)