> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/uwp/annotation/customize-popup.md).

# Customize annotation interactions in UWP viewer

Learn how to customize the Annotation PopupCommandMenu on your viewer by adding or removing options. Replace the Delete button with a custom one using sample code. Default and customized menu options

## 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`.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// 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
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| Default Menu Options                                                                                                                                                                                                                            | Customized Menu Options                                                                                                                                                                                                                         |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](https://3246663708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Frgmys2szYV2Z567Zu3vi%2Fuploads%2Fgit-blob-3195d9dfbc0bc0be8c050f1a0e081da9aa439818%2F942ce9f0403fe4f5194c41005cebc289080e5f10-382x536.png?alt=media) | ![](https://3246663708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Frgmys2szYV2Z567Zu3vi%2Fuploads%2Fgit-blob-eb408c5665fca4e2d32a711116ffc95ec9a16cfb%2Ffdf438ffab0dfd1d01abf4a872437b0645752670-402x546.png?alt=media) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/uwp/annotation/customize-popup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
