Menu Item Selection

This sample demonstrates the MenuItemClick event and SelectedItem tracking on the Menu component.


Horizontal Menu with Selection

Click a menu item. The MenuItemClick event fires and reports the selected item.

Last clicked:None — click a menu item
Click count: 0

Vertical Menu with Selection


Code Example

<Menu Orientation="Orientation.Horizontal"
      MenuItemClick="HandleItemClick">
    <Items>
        <MenuItem Text="Home" Value="home" />
        <MenuItem Text="Products" Value="products">
            <MenuItem Text="Software" Value="software" />
        </MenuItem>
    </Items>
</Menu>

@code {
    private string _clickedText;

    void HandleItemClick(MenuEventArgs e)
    {
        _clickedText = e.Item.Text;
        // e.Item.Value, e.Item.ValuePath also available
    }
}