AnnotationStore.GetAnnotations 方法

定義

傳回存放區中包含的註解清單。

多載

GetAnnotations()

傳回存放區中的所有註解清單。

GetAnnotations(ContentLocator)

傳回註解清單,這些註解擁有的 Anchors 具有從相符 ContentLocatorPart 順序起始的定位器。

範例

下列範例示範如何使用 GetAnnotations 方法來判斷存放區中是否包含任何批註。

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

傳回存放區中的所有註解清單。

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)

傳回

IList<Annotation>

目前包含在存放區中的所有註解清單。

例外狀況

已在存放區中呼叫 Dispose

範例

下列範例示範如何使用 GetAnnotations 方法來判斷存放區中是否包含任何批註。

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

傳回註解清單,這些註解擁有的 Anchors 具有從相符 ContentLocatorPart 順序起始的定位器。

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)

參數

anchorLocator
ContentLocator

要傳回其相符註解的起始 ContentLocatorPart 順序。

傳回

IList<Annotation>

註解清單,這些註解擁有的 Anchors 具有啟動和符合指定之 anchorLocator 的定位器;如果找不到符合的註解,則為 null

備註

這個 GetAnnotations 方法會在內部使用 StartsWith 類別的 ContentLocator 方法來搜尋並比對要傳回的注釋。

另請參閱

適用於