Infragistics(R) NetAdvantage(R) : WPF 2012.1
Adding and Removing Items
E-mail your feedback on this topic.
Shared XAML > Menus > xamMenu > Using xamMenu > Adding and Removing Items

Glossary Item Box

You can add and remove menu items in xamMenu or xamContextMenu. To add an item to the items collection, use the Add method of the menu or menu item's Item Collection. There are two remove methods: Remove and RemoveAt which exists on the Item Collection as well.

The following code shows you how to add and remove items in xamMenu.

In Visual Basic:

' Create Edit menu item
Dim parentMenuItem As New XamMenuItem()
parentMenuItem.Header = "Edit"

menu1.Items.Add(parentMenuItem)

' Remove a submenu item
Dim item As XamMenuItem = TryCast(menu1.Items(0), XamMenuItem)
item.Items.RemoveAt(0)

In C#:

// Create a menu item
XamMenuItem parentMenuItem = new XamMenuItem();
parentMenuItem.Header = "Edit";
// Add menu item
menu1.Items.Add(parentMenuItem);

// Remove a submenu item
XamMenuItem item = menu1.Items[0] as XamMenuItem;
item.Items.RemoveAt(0);

Related Topics

Binding to Data

Layout Settings

Navigating Pages Using xamMenu

Adding Separators between XamMenuItems

Adding Icons to XamMenuItems

Adding Check Boxes to XamMenuItems