MenuItemStyleCollection Class
Assembly: System.Web (in system.web.dll)
The MenuItemStyleCollection class is used to store and manage a collection of MenuItemStyle objects in a Menu control. The Menu control uses the MenuItemStyleCollection class as the underlying data type of the LevelMenuItemStyles and LevelSelectedStyles properties.
The LevelMenuItemStyles and LevelSelectedStyles properties are an alternative to the individual style properties (such as StaticMenuItemStyle). These properties are applied to regular menu items and the selected menu item, respectively, based on the menu item's level in the menu. The first style in the collection corresponds to the menu item style for the first level of the menu. The second style in the collection corresponds to the menu item style for the second level of the menu, and so on. The LevelMenuItemStyles and LevelSelectedStyles properties are most often used to generate menus where menu items at a certain level have the same appearance, regardless of whether they have submenus.
The MenuItemStyleCollection class inherits most of its members from the StateManagedCollection class. For more information on the inherited members, see StateManagedCollection.
The following code example demonstrates how to use the MenuItemStyleCollection class to specify the style settings for the menu items in a Menu control based on the menu item's level. In this example, the LevelMenuItemStyles property is created declaratively, and one MenuItemStyle object is removed and another added to the MenuItemStyleCollection object.
- AspNetHostingPermission for running the MenuItemStyleCollection control in a hosted environment. Associated enumeration: Minimal
System.Web.UI.StateManagedCollection
System.Web.UI.WebControls.MenuItemStyleCollection