> For the complete documentation index, see [llms.txt](https://adospace.gitbook.io/mauireactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adospace.gitbook.io/mauireactor/how-to-create-a-menu-contextmenu.md).

# How to create a Menu/ContextMenu?

.NET Maui allows developers to create Menus and ContextMenu for desktop apps.&#x20;

In MauiReactor you can easily add a Menu bar to a desktop application by adding the `MenuBarItem` control under a page like it's shown in the following example:

```csharp
new ContentPage
{
    new MenuBarItem("File")
    {
        new MenuFlyoutSubItem("Project")
        {
            new MenuFlyoutItem("Open...")
                .OnClicked(OnOpenProject),
        },
        new MenuFlyoutSeparator(),
        new MenuFlyoutItem("Exit")
            .OnClicked(OnExitApplication),
    },

    RenderBody()
}
```

For the context menu, you have to add the MenuFlyout under the control that should show the menu like it's shown below:

```csharp
new Label(person.Initial)
{
    new MenuFlyout
    {
        new MenuFlyoutItem("MenuItem1")
            .OnClicked(()=>OnClickMenuItem("MenuItem1")),
        new MenuFlyoutItem("MenuItem2")
            .OnClicked(()=>OnClickMenuItem("MenuItem2")),
        new MenuFlyoutItem("MenuItem3")
            .OnClicked(()=>OnClickMenuItem("MenuItem3")),
    }
}
```

{% hint style="warning" %}
Please note that not all controls support the context menu (like the ViewCell): for a list of unsupported controls please refer to official .NET MAUI documentation.
{% endhint %}


---

# 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://adospace.gitbook.io/mauireactor/how-to-create-a-menu-contextmenu.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.
