Some test text!

Search
Hamburger Icon

UWP / Guides / Config annotation tools

Customize annotation interactions in UWP viewer

Customizing Annotation PopupCommandMenu

It is possible to customize the popup annotation menu on the viewer by adding or removing options when creating, selecting and editing annotations.

Example

The sample code below shows how to replace the Delete button for a custom one by listening to OnShowPopupMenu and checking the ShowingPopupMenuEventArgs.

// Subscrive to OnShowPopupMenu event
ToolManager.OnShowPopupMenu += ToolManager_OnShowPopupMenu;

// Raised event
private void ToolManager_OnShowPopupMenu(PopupCommandMenu menu, pdftron.PDF.Tools.ShowingPopupMenuEventArgs eventArgs)
{
     // Check if tool type is Editing Annotation
     if (eventArgs.ToolType == ToolType.e_annot_edit)
     {
          // Check if annotation type is Square
          if (eventArgs.AnnotType == AnnotType.e_Square)
          {
               // Find Delete button and remove it
               menu.MenuItems.Remove(menu.MenuItems.Where(x => x.Tag.ToString() == "delete").FirstOrDefault());                

               // Create a custom button with a custom event/action
               Button button = new Button();
               button.Content = "Click Me";
               button.Click += Button_Click;

               /* It accepts a bool parameter that tells if should use
                * default style or not on the newly added button */
               menu.AddMenuItem(button, true);
          }
     }
}

private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
     // my actions
}
Default Menu OptionsCustomized Menu Options
Default Rect MenuCustom Rect Menu

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales