> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/gum-tool/plugins/pluginbase.addmenuitem.md).

# AddMenuItem

## Introduction

The AddMenuEntry function adds items to Gum's main menu. It takes the action to run when the item is clicked, followed by the menu path: the first string names the top-level menu (an existing one such as "Content", or a new one, which is inserted before "Help") and each following string is a submenu or, last, the item itself.

AddMenuEntry returns a MenuItemModel. This is a plain object with Header, IsEnabled, IsCheckable, IsChecked, and ToolTip properties; changing them updates the rendered menu item. The same call works in both the WPF tool and the Avalonia tool, so a plugin that only uses AddMenuEntry does not need to reference any UI framework.

## Code Example

The following shows how to create a menu called "My Plugin" which contains two items: First and Second. Clicking each item shows a message through the injected dialog service. Add the following to your plugin's **StartUp** function.

```csharp
// Add startup logic here:
AddMenuEntry(() => _dialogService.ShowMessage("You clicked first"), "My Plugin", "First");

var second = AddMenuEntry(() => _dialogService.ShowMessage("You clicked second"), "My Plugin", "Second");

// The returned model can be changed later, for example after a tab is shown or hidden:
second.Header = "Second (visited)";
```

![](https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-089a28d257904e72304fbbcf0ced34081b8b5f7a%2FBeforeClickingFirstGum.png?alt=media)

## AddMenuItem (obsolete)

Older plugins called AddMenuItem, which returned a WPF System.Windows.Controls.MenuItem and required subscribing to its Click event. That overload is still available on WpfPluginBase in the WPF tool, marked obsolete, and is removed along with WPF itself when the tool retires it. Replace it with AddMenuEntry: move the Click handler into the action argument, and change any Header or IsEnabled updates to the returned MenuItemModel.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/gum/gum-tool/plugins/pluginbase.addmenuitem.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
