AnnotationStore.DeleteAnnotation(Guid) 方法

定义

从存储区中删除具有指定 Id 的批注。

public:
 abstract System::Windows::Annotations::Annotation ^ DeleteAnnotation(Guid annotationId);
public abstract System.Windows.Annotations.Annotation DeleteAnnotation (Guid annotationId);
abstract member DeleteAnnotation : Guid -> System.Windows.Annotations.Annotation
Public MustOverride Function DeleteAnnotation (annotationId As Guid) As Annotation

参数

annotationId
Guid

要删除的注释的 GUID Id 属性。

返回

Annotation

已删除的批注;如果在存储区中未找到具有指定 null 的批注,则为 annotationId

例外

已在存储区上调用 Dispose

示例

以下示例演示了 DeleteAnnotation 如何使用和 Flush 方法。

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

适用于

另请参阅