Edit

Kongsi melalui


AnnotationStore.GetAnnotations Method

Definition

Returns a list of annotations contained in the store.

Overloads

GetAnnotations()

Returns a list of all the annotations in the store.

GetAnnotations(ContentLocator)

Returns a list of annotations that have Anchors with locators that begin with a matching ContentLocatorPart sequence.

Examples

The following example shows how to use the GetAnnotations method to determine if there are any annotations contained in the store.

// ---------------------------- CloseFile -----------------------------
private void CloseFile()
{
    // If there are existing annotations, then they should be saved.
    if (_annStore.GetAnnotations().Count > 0)
    {
        string backupFile = _fileName + ".annotations" + ".xml";
        FileStream backupStream = new FileStream(backupFile, FileMode.Create);
        CopyStream(_annotationBuffer, backupStream);
        _annStore.Flush();
        _annServ.Disable();
    }
}

GetAnnotations()

Returns a list of all the annotations in the store.

public:
 abstract System::Collections::Generic::IList<System::Windows::Annotations::Annotation ^> ^ GetAnnotations();
public abstract System.Collections.Generic.IList<System.Windows.Annotations.Annotation> GetAnnotations ();
abstract member GetAnnotations : unit -> System.Collections.Generic.IList<System.Windows.Annotations.Annotation>
Public MustOverride Function GetAnnotations () As IList(Of Annotation)

Returns

The list of all annotations currently contained in the store.

Exceptions

Dispose has been called on the store.

Examples

The following example shows how to use the GetAnnotations method to determine if there are any annotations contained in the store.

// ---------------------------- CloseFile -----------------------------
private void CloseFile()
{
    // If there are existing annotations, then they should be saved.
    if (_annStore.GetAnnotations().Count > 0)
    {
        string backupFile = _fileName + ".annotations" + ".xml";
        FileStream backupStream = new FileStream(backupFile, FileMode.Create);
        CopyStream(_annotationBuffer, backupStream);
        _annStore.Flush();
        _annServ.Disable();
    }
}

See also

Applies to

GetAnnotations(ContentLocator)

Returns a list of annotations that have Anchors with locators that begin with a matching ContentLocatorPart sequence.

public:
 abstract System::Collections::Generic::IList<System::Windows::Annotations::Annotation ^> ^ GetAnnotations(System::Windows::Annotations::ContentLocator ^ anchorLocator);
public abstract System.Collections.Generic.IList<System.Windows.Annotations.Annotation> GetAnnotations (System.Windows.Annotations.ContentLocator anchorLocator);
abstract member GetAnnotations : System.Windows.Annotations.ContentLocator -> System.Collections.Generic.IList<System.Windows.Annotations.Annotation>
Public MustOverride Function GetAnnotations (anchorLocator As ContentLocator) As IList(Of Annotation)

Parameters

anchorLocator
ContentLocator

The starting ContentLocatorPart sequence to return matching annotations for.

Returns

The list of annotations that have Anchors with locators that start and match the given anchorLocator; otherwise, null if no matching annotations were found.

Remarks

This GetAnnotations method internally uses the StartsWith method of the ContentLocator class to search and match for the annotations to return.

See also

Applies to