共用方式為


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

範例

下列範例示範 如何使用 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();
}

適用於

另請參閱