NavBarGroup Class

Represents an individual group within the NavBarControl.

Namespace: DevExpress.Xpf.NavBar

Assembly: DevExpress.Xpf.NavBar.v20.1.dll

Declaration

public class NavBarGroup :
    DXFrameworkContentElement,
    INavigationItem,
    INotifyPropertyChanged,
    ICommandSource
Public Class NavBarGroup
    Inherits DXFrameworkContentElement
    Implements INavigationItem,
               INotifyPropertyChanged,
               ICommandSource

Remarks

A navbar control maintains collections of groups and items. Groups are represented by instances of the NavBarGroup class which can be accessed via the NavBarControl.Groups property. This property returns the NavBarGroupCollection collection which allows you to add and delete groups within the navbar.

Use properties of the NavBarGroup class to specify the appearance and behavior of an individual group. Use the NavBarGroup.Header and NavBarGroup.ImageSource properties to define the caption text of a group and an image to be displayed within the group's header. A group's visibility can be controlled via the NavBarGroup.IsVisible property. The content of a group can be defined by either the NavBarGroup.Items or NavBarGroup.Content property, depending upon the NavBarGroup.DisplaySource property setting.

Set the NavBarGroup.IsExpanded property to true to expand a group; set it to false to collapse it. Use the NavBarGroup.SelectedItem or NavBarGroup.SelectedItemIndex property to determine a group's selected item.

Using the NavBarGroup.VisualStyle property you can define a visual style to be applied to a group. The appearance of a group's items can be controlled by using the NavBarGroup.ItemVisualStyle property.

To learn more, see the Groups topic.

Examples

This example demonstrates how items can be created and customized programmatically within a navbar group.

In this sample, images are defined for the group header and the third group item via the NavBarGroup.ImageSource and NavBarItem.ImageSource properties, respectively. The item image's layout is customized by assigning the item's NavBarItem.VisualStyle property with a specific style that makes use of the NavBarViewBase.LayoutSettings attached property's LayoutSettings.ImageDocking setting.

private void CreateGroup1(NavBarControl navBar){
    NavBarGroup group1 = new NavBarGroup();
    group1.Header = "Items";
    //Display an image within the group's header
    group1.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Images/folder.png"));

    NavBarItem item1 = new NavBarItem();
    item1.Content = "Home";
    group1.Items.Add(item1);

    NavBarItem item2 = new NavBarItem();
    item2.Content = "Work";
    group1.Items.Add(item2);

    NavBarItem item3 = new NavBarItem();
    item3.Content = "Private";
    //Display an image within the item
    item3.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Images/private.png"));
    //Change item image layout
    Style itemStyle = new Style();
    itemStyle.Setters.Add(new Setter(NavBarViewBase.LayoutSettingsProperty, new LayoutSettings() { ImageDocking = Dock.Right }));
    item3.VisualStyle = itemStyle;
    group1.Items.Add(item3);

    navBar.Groups.Add(group1);
}
See Also