Live Chat Icon For mobile
Live Chat Icon

How can I create an application that is used to declare a Context Menu with routed commands that the users can access to create and manage annotations ?

Platform: WPF| Category: Annotations

Users typically create annotations by first selecting some text or an item of interest and then right-clicking to display a context menu of annotation options.

The following example shows the XAML you can use to declare a Context Menu with routed commands that users can access to create and manage annotations.

[XAML]

<DocumentViewer.ContextMenu>
  <ContextMenu>
    <MenuItem Command='ApplicationCommands.Copy' />
    <Separator />
    <!-- Add a Highlight annotation to a user selection. -->
    <MenuItem Command='ann:AnnotationService.CreateHighlightCommand'
              Header='Add Highlight' />
    <!-- Add a Text Note annotation to a user selection. -->
    <MenuItem Command='ann:AnnotationService.CreateTextStickyNoteCommand'
              Header='Add Text Note' />
    <!-- Add an Ink Note annotation to a user selection. -->
    <MenuItem Command='ann:AnnotationService.CreateInkStickyNoteCommand'
              Header='Add Ink Note' />
    <Separator />
    <!-- Remove Highlights from a user selection. -->
    <MenuItem Command='ann:AnnotationService.ClearHighlightsCommand'
              Header='Remove Highlights' />
    <!-- Remove Text Notes and Ink Notes from a user selection. -->
    <MenuItem Command='ann:AnnotationService.DeleteStickyNotesCommand'
              Header='Remove Notes' />
    <!-- Remove Highlights, Text Notes, Ink Notes from a selection. -->
    <MenuItem Command='ann:AnnotationService.DeleteAnnotationsCommand'
              Header='Remove Highlights & Notes' />
  </ContextMenu>
</DocumentViewer.ContextMenu>

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.