Skip to main content

PdfViewerControl.HitTest(Point) Method

Gets the visual element located under the point.

Namespace: DevExpress.Xpf.PdfViewer

Assembly: DevExpress.Xpf.PdfViewer.v23.2.dll

NuGet Package: DevExpress.Wpf.PdfViewer

Declaration

public PdfHitTestResult HitTest(
    Point point
)

Parameters

Name Type Description
point Point

A Point structure that specifies the hit point coordinates relative to the control’s top-left corner.

Returns

Type Description
PdfHitTestResult

A PdfHitTestResult object that identifies the visual element located under the point.

Remarks

The HitTest property allows you to identify the type of a visual element located under the test object.

Example

View Example: https://github.com/DevExpress-Examples/how-to-determine-the-page-number-of-a-clicked-page

This example shows how to determine what page was clicked in a document using the PdfViewerControl.HitTest method of the PdfViewerControl.

using DevExpress.Xpf.PdfViewer;
using System.Windows;
using System.Windows.Input;

namespace DeterminePageNumber {

    public partial class MainWindow : Window {


        public MainWindow() {
            InitializeComponent();
            pdfViewer.OpenDocument("..\\..\\demo.pdf");
        }

        private void pdfViewer_MouseDown(object sender, MouseButtonEventArgs e) {
            PdfHitTestResult result = pdfViewer.HitTest(e.GetPosition(pdfViewer));
            MessageBox.Show(string.Format("You clicked on page {0}", result.DocumentPosition.PageNumber));
        }
    }
}
See Also