Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

AnnotationService Class

Provides core services of the Microsoft Annotations Framework to manage and display user annotations.

System.Object
  System.Windows.Threading.DispatcherObject
    System.Windows.Annotations.AnnotationService

Namespace:  System.Windows.Annotations
Assembly:  PresentationFramework (in PresentationFramework.dll)

public sealed class AnnotationService : DispatcherObject

The AnnotationService type exposes the following members.

  NameDescription
Public methodAnnotationService(DocumentViewerBase)Initializes a new instance of the AnnotationService class for use with a specified DocumentViewer or FlowDocumentPageViewer control.
Public methodAnnotationService(FlowDocumentReader)Initializes a new instance of the AnnotationService class for use with a specified FlowDocumentReader control.
Public methodAnnotationService(FlowDocumentScrollViewer)Initializes a new instance of the AnnotationService class for use with a specified FlowDocumentScrollViewer control.
Top

  NameDescription
Public propertyDispatcherGets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Public propertyIsEnabledGets a value that indicates whether the AnnotationService is enabled.
Public propertyStoreGets the AnnotationStore used by this AnnotationService.
Top

  NameDescription
Public methodCheckAccessDetermines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Public methodDisableDisables annotations processing and hides all visible annotations.
Public methodEnableEnables the AnnotationService for use with a given AnnotationStore and displays all visible annotations.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodStatic memberGetService(DocumentViewerBase)Returns the AnnotationService instance associated with a specified document viewing control.
Public methodStatic memberGetService(FlowDocumentReader)Returns the AnnotationService associated with a specified FlowDocumentReader.
Public methodStatic memberGetService(FlowDocumentScrollViewer)Returns the AnnotationService associated with a specified FlowDocumentScrollViewer.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodVerifyAccessEnforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Top

  NameDescription
Public fieldStatic memberClearHighlightsCommandRepresents the command to clear highlight annotations from the current selection.
Public fieldStatic memberCreateHighlightCommandRepresents the command to create a highlight annotation on the current selection.
Public fieldStatic memberCreateInkStickyNoteCommandRepresents the command to create an ink-note annotation on the current selection.
Public fieldStatic memberCreateTextStickyNoteCommandRepresents the command to create a text-note annotation on the current selection.
Public fieldStatic memberDeleteAnnotationsCommandRepresents the command to delete all ink-note, text-note, and highlight annotations in the current selection.
Public fieldStatic memberDeleteStickyNotesCommandRepresents the command to delete all ink-note and text-note annotations in the current selection.
Top

The following example shows how to create and start an AnnotationService.

// ------------------------ StartAnnotations -------------------------- 
/// <summary> 
///   Enables annotations and displays all that are viewable.</summary> 
private void StartAnnotations()
{
    // If there is no AnnotationService yet, create one. 
    if (_annotService == null)
        // docViewer is a document viewing control named in Window1.xaml.
        _annotService = new AnnotationService(docViewer);

    // If the AnnotationService is currently enabled, disable it. 
    if (_annotService.IsEnabled == true)
        _annotService.Disable();

    // Open a stream to the file for storing annotations.
    _annotStream = new FileStream(
        _annotStorePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);

    // Create an AnnotationStore using the file stream.
    _annotStore = new XmlStreamStore(_annotStream);

    // Enable the AnnotationService using the new store.
    _annotService.Enable(_annotStore);
}// end:StartAnnotations()

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft