AnnotationService Constructor

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the AnnotationService class for use with a specified document viewing control.

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

NameDescription
System_CAPS_pubmethodAnnotationService(DocumentViewerBase)

Initializes a new instance of the AnnotationService class for use with a specified DocumentViewer or FlowDocumentPageViewer control.

System_CAPS_pubmethodAnnotationService(FlowDocumentReader)

Initializes a new instance of the AnnotationService class for use with a specified FlowDocumentReader control.

System_CAPS_pubmethodAnnotationService(FlowDocumentScrollViewer)

Initializes a new instance of the AnnotationService class for use with a specified FlowDocumentScrollViewer control.

The AnnotationService can be used with the following document viewing controls:

The following example shows use of the AnnotationService constructor.

// ------------------------ 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()
Return to top
Show: