Menu

Note: You can check the Avalonia docs for the Menu APIarrow-up-right and Menuarrow-up-right if you need more information.

For Avalonia.FuncUI's DSL properties you can check Menu.fsarrow-up-right

The menu control allows you to add a list of buttons in a horizontal manner which supports sub-items, it's usually put at the top of the application inside a DockPanel, but it can be placed anywhere in the application.

Usage

Top-Level Menu Items

To create top-level navigation menus you just need to provide a list of MenuItem controls and use the .viewItems property on the Menuarrow-up-right control

let menuItems = [
    MenuItem.Create [
        MenuItem.header "File"
    ]
    MenuItem.Create [
        MenuItem.header "Edit"
    ]
]

Menu.create [
  Menu.viewItems menuItems
]

Set Sub-Menus

Each MenuItem can contain MenuItems themselves if you need a sub-menu you just need to provide the appropriate children

Set Icons

To add Icons to the menu item you just need to provide an Imagearrow-up-right, you can check this samplearrow-up-right which uses an extension method defined in this filearrow-up-right

Dispatch Actions From Menu Items

Last updated