AnnotationHelper.CreateHighlightForSelection Method

Definition

Creates a highlight annotation on the current selection of the viewer control associated with the specified AnnotationService.

public:
 static System::Windows::Annotations::Annotation ^ CreateHighlightForSelection(System::Windows::Annotations::AnnotationService ^ service, System::String ^ author, System::Windows::Media::Brush ^ highlightBrush);
public static System.Windows.Annotations.Annotation CreateHighlightForSelection (System.Windows.Annotations.AnnotationService service, string author, System.Windows.Media.Brush highlightBrush);
static member CreateHighlightForSelection : System.Windows.Annotations.AnnotationService * string * System.Windows.Media.Brush -> System.Windows.Annotations.Annotation
Public Shared Function CreateHighlightForSelection (service As AnnotationService, author As String, highlightBrush As Brush) As Annotation

Parameters

service
AnnotationService

The annotation service to use to create the highlight annotation.

author
String

The author of the annotation.

highlightBrush
Brush

The brush to use to draw the highlight over the selected content.

Returns

The highlight annotation; or null, if there is no selected content to highlight.

Exceptions

service is null.

service is not enabled.

-or-

highlightBrush in not a SolidColorBrush.

The viewer control contains no content selection.

Remarks

The highlight annotation is anchored to the content defined by the current selection of the DocumentViewerBase, DocumentViewer, FlowDocumentPageViewer, FlowDocumentScrollViewer, or FlowDocumentReader control specified to the AnnotationService constructor.

If there is no selected content (the selection length is zero length), no annotation is created and an InvalidOperationException is thrown.

author can be specified as null in which case no author is defined.

If highlightBrush is null, the default highlight brush of the given annotation service is used.

The given annotation service must be enabled by means of a call to AnnotationService.Enable prior to calling CreateHighlightForSelection.

Applies to

See also