Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PdfHitTestResult.IsSelected Property

Indicates whether an annotation, image or text is selected.

Namespace: DevExpress.Xpf.PdfViewer

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

NuGet Package: DevExpress.Wpf.PdfViewer

#Declaration

public bool IsSelected { get; }

#Property Value

Type Description
Boolean

true, if an annotation, image or text is selected; otherwise, false.

#Example

View Example: https://github.com/DevExpress-Examples/how-to-determine-the-page-content-type-under-the-mouse-pointer

This example illustrates how to use the PdfViewerControl.HitTest method to determine the type of the page content under the mouse pointer.

This method returns a PdfHitTestResult instance with information about the page content type (text, an image or annotation). You can get the page content type using the PdfHitTestResult.ContentType property and the page content selection status using the PdfHitTestResult.IsSelected property.

In this example, the retrieved information is shown on the Content Type ribbon page group.

Call the PdfViewerControl.HitTest method in the PdfViewerControl.MouseMove event handler to perform hit testing.

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

namespace DetermineContentType {

    public partial class MainWindow : Window {

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

        private void viewer_MouseMove(object sender, MouseEventArgs e) {

            PdfHitTestResult result = viewer.HitTest(e.GetPosition(viewer));
            string contentTypeText = result.IsSelected ? "Selected " : "Unselected ";

            switch (result.ContentType) {
                case PdfDocumentContentType.Text:
                contentTypeText = contentTypeText + "Text";
                break;
                case PdfDocumentContentType.Image:
                contentTypeText = contentTypeText + " Image";
                break;
                case PdfDocumentContentType.Annotation:
                contentTypeText = contentTypeText + "Annotation";
                break;
                default:
                contentTypeText = "The content is empty";
                break;
            }
            barButtonItem.Content = contentTypeText;
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the IsSelected property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also