AnnotationService.Enable Method (AnnotationStore)

 

Enables the AnnotationService for use with a given AnnotationStore and displays all visible annotations.

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

public void Enable(
	AnnotationStore annotationStore
)

Parameters

annotationStore
Type: System.Windows.Annotations.Storage.AnnotationStore

The annotation store to use for reading, writing, and displaying annotations.

Exception Condition
ArgumentNullException

annotationStore is null.

When Enable is called all annotations in the viewer control window are displayed. (The viewer control associated with the annotation service is specified in the parameter to the AnnotationService constructor.)

The following example shows how to use the Enable method when you 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
Available since 3.0
Return to top
Show: