Share via


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

适用于

另请参阅