[]
        
(Showing Draft Content)

Item Selection

When a user selects a menu item, the menu raises the ItemSelected event. Your handler decides what happens next. Use the event to connect the menu to the rest of your app, for example to:

  • Update the content that the app displays

  • Navigate to a related view

  • Run an item-specific action


Handle the ItemSelected Event

The ItemSelected event occurs when a user selects an item, including a parent item. The handler receives an ItemSelectedEventArgs object. Its Item property returns the selected item.

Because users can select parent items, write the handler so that it handles items that represent groups as well as items that represent content.

The following example displays a view for each item. Parent items are selectable, so the handler also tests mail:

c1HamburgerMenu1.ItemSelected += (s, e) =>
{
    if (e.Item == schedule) ShowSchedule();
    else if (e.Item == mail || e.Item == inbox) ShowInbox();
    else if (e.Item == drafts) ShowDrafts();
};

Use else if for every branch, so that the handler displays only one view for each selection.