AnnotationService Constructor (FlowDocumentScrollViewer)

 

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

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

public AnnotationService(
	FlowDocumentScrollViewer viewer
)

Parameters

viewer
Type: System.Windows.Controls.FlowDocumentScrollViewer

The document viewing control associated with the AnnotationService.

Exception Condition
ArgumentNullException

viewer is null.

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()

.NET Framework
Available since 3.0
Return to top
Show: