This documentation is archived and is not being maintained.

AnnotationService.Enable Method

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
You cannot use methods in XAML.


Type: System.Windows.Annotations.Storage.AnnotationStore

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


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. For the full sample, see DocumentViewer with Annotations XML-Store Sample.

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

    // 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.
}// end:StartAnnotations()

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0