Clicking and Selecting Items
- 2 minutes to read
When navigating through DXNavBar control items, end-users can perform specific item actions, such as clicking and selecting items.
When an end-user clicks an item within the DXNavBar control, the NavBarItem.Click event is generated allowing you to respond to the user action. You can also assign a command to a NavBarItem via the NavBarItem.Command property.
The automatic item selection feature allows the last clicked items to be visually indicated and programmatically identified. DXNavBar allows either a single item to be selected within the control, or each group to have its own selected item. By default, item selection is enabled, so clicking items within DXNavBar highlights them and changes their specific characteristics.
To define the item selection mode (single item or multiple items), use a combination of the NavBarControl.AllowSelectItem and NavBarControl.EachGroupHasSelectedItem properties. In addition, the NavBarControl.AllowSelectDisabledItem property can be used to allow end-users to select disabled items (items whose DXFrameworkContentElement.IsEnabled property is false). The selection state of an individual item can be identified via its NavBarItem.IsSelected property. You can also use the NavBarCommands.SelectItem command to select the item you desire.
Commonly, when an end-user clicks an item to select it, you can respond to this action by handling specific events occurring in the following order: NavBarViewBase.Click, NavBarViewBase.ItemSelecting (this event allows you to cancel item selection), NavBarViewBase.ItemSelected and NavBarItem.Select.
Single Item Selection
If the NavBarControl.AllowSelectItem property is set to true and the NavBarControl.EachGroupHasSelectedItem property is set to false, only one item can be selected within DXNavBar control. In this mode, you can determine the selected item via the control’s NavBarControl.SelectedItem property.
Multiple Item Selection
If both the NavBarControl.AllowSelectItem and NavBarControl.EachGroupHasSelectedItem properties are enabled, each group can have its own selected item. In this case, a list of items selected within the control can be accessed by using the NavBarControl.SelectedItems property. Within groups, selected items can be manipulated via the NavBarGroup.SelectedItem or NavBarGroup.SelectedItemIndex property.