共用方式為


XmlStreamStore.DeleteAnnotation(Guid) 方法

定義

將含有指定之 Id 的註解從存放區中刪除。

public:
 override System::Windows::Annotations::Annotation ^ DeleteAnnotation(Guid annotationId);
public override System.Windows.Annotations.Annotation DeleteAnnotation (Guid annotationId);
override this.DeleteAnnotation : Guid -> System.Windows.Annotations.Annotation
Public Overrides Function DeleteAnnotation (annotationId As Guid) As Annotation

參數

annotationId
Guid

所要刪除註釋的全域唯一識別碼 (GUID) Id 屬性。

傳回

已刪除的註解;如果在存放區中找不到含有指定之 null 的註解,則為 annotationId

例外狀況

已在存放區中呼叫 Dispose

尚未設定存放區的 I/O Stream

範例

下列範例示範 如何使用 DeleteAnnotationFlush 方法。

// ------------------------- DeleteMark_Click -------------------------
void DeleteMark_Click(object sender, RoutedEventArgs e)
{
    Annotation ann = ((MenuItem)sender).Tag as Annotation;
    _annStore.DeleteAnnotation(ann.Id);
    _annStore.Flush();

    MenuItem thisMenu = sender as MenuItem;
    ContextMenu parentMenu = thisMenu.Parent as ContextMenu;
    FrameworkElement dObj =
        parentMenu.PlacementTarget as FrameworkElement;
    while (!(dObj is StackPanel))
    {
        dObj = dObj.Parent as FrameworkElement;
    }

    ListBox collection = dObj.Parent as ListBox;
    collection.Items.Remove(dObj);
    Util.FlushDispatcher();
}

適用於

另請參閱