How to Disable Keyboard Shortcuts in WPF PDF Viewer?
In the WPF PDF Viewer, keyboard shortcuts can be deactivated by managing the PreviewKeyDown
event. To achieve this, set e.Handled = true
within the event handler. This ensures that all key events are blocked from reaching the internal handlers of the PDF Viewer, thereby disabling its default keyboard shortcut functionality.
Steps to disable keyboard shortcuts in WPF PDF Viewer
Step 1:
- Hook the
PreviewKeyDown
event to the PdfViewer
pdfViewer.PreviewKeyDown += PdfViewerControl_PreviewKeyDown;
Step 2:
- Within the PreviewKeyDown event, assign
e.Handled = true
to indicate that the event has been handled. This action halts further tunneling to additional handlers, thereby stopping the shortcut action before WPF processes it.
private void PdfViewerControl_PreviewKeyDown(object sender, KeyEventArgs e)
{
//Marking the event as handled so that default WPF logicdoesn'tt intercept
e.Handled = true;
}
A complete working sample to disable keyboard shortcuts in WPD PDF Viewer can be downloaded from GitHub.
Conclusion
I hope you enjoyed learning about how to disable keyboard shortcuts in the WPF PDF Viewer Control.
You can refer to our WPF PDF Viewer page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!