Skip to main content

Group Content Model

  • 3 minutes to read

This topic describes how the content of two group elements - the group header and the group client region - can be defined using specific content properties, and how a group (that is a content element) is referred to within the visual tree.

Header Content

A group’s heading is provided using the NavBarGroup.Header property, which is of type Object, and so can be any type. Typically, group headers display explanatory information about group contents.

Group Content

The content of a group’s client region can be defined by using the NavBarGroup.Items or NavBarGroup.Content property.

  • The NavBarGroup.Items property provides access to the NavBarItemCollection object, and it allows you to create and manipulate a list of items to be displayed within a group.
  • Using the NavBarGroup.Content property, you can provide any custom content for a group. The NavBarGroup.Content property is of type Object, so there are no restrictions on what you can put in group content.

To control how (using which of these properties) group content should be represented, a group provides a specific NavBarGroup.DisplaySource property, which can be set to the DisplaySource.Items or DisplaySource.Content value, respectively.

Note

The NavBarGroup.Items property is, by design, specified as the default property and the content property of a group. This, for example, allows you to declare items in XAML directly after a group declaration, without wrapping them into opening and closing NavBarGroup.Items tags.

The default value of the NavBarGroup.DisplaySource property is DisplaySource.Items, which means that this content type is applied to a group, when the DisplaySource property declaration is omitted within XAML.

The following code demonstrates different methods of group content declaration in XAML.

<dxn:NavBarControl Name="navBarControl1" >
    <dxn:NavBarControl.Groups>
        <dxn:NavBarGroup Header="Group1" DisplaySource="Items">
            <dxn:NavBarGroup.Items>
                <dxn:NavBarItem>Item1</dxn:NavBarItem>
                <dxn:NavBarItem>Item2</dxn:NavBarItem>
            </dxn:NavBarGroup.Items>
        </dxn:NavBarGroup>

        <dxn:NavBarGroup Header="Group2" DisplaySource="Content">
            <dxn:NavBarGroup.Content>
                <TextBlock Text="Group content text"></TextBlock>
            </dxn:NavBarGroup.Content>
        </dxn:NavBarGroup>

        <!-- Simple item declaration -->
        <dxn:NavBarGroup Header="Group3">
            <dxn:NavBarItem>Item1</dxn:NavBarItem>
            <dxn:NavBarItem>Item2</dxn:NavBarItem>
            <dxn:NavBarItem>Item3</dxn:NavBarItem>
        </dxn:NavBarGroup>
    </dxn:NavBarControl.Groups>

    <dxn:NavBarControl.View>
        <dxn:ExplorerBarView />
    </dxn:NavBarControl.View>
</dxn:NavBarControl>

This code results in the following visual representation:

Groups-ContentModel.png

Groups in Visual Tree

DXNavBar groups (represented by NavBarGroup instances) are content elements (they derive from ContentElement), and so they are not part of the visual tree; they do not inherit from Visual and do not have a visual representation. In the DXNavBar, the NavBarGroupControl type represents a group in the visual tree and serves as a content host for the group. Since individual groups can be visually represented by different visual elements within the DXNavBar control, a group can be exposed by several NavBarGroupControl objects in the visual tree.

For instance, within the Navigation Pane View, an active group might be referred to by the following visual elements: the expanded group, the corresponding group header or item within the Overflow Panel, or a button within a collapsed Navigation Pane (a click on this button invokes a popup window displaying the active group’s contents). These visual elements are represented by individual NavBarGroupControl instances in the visual tree. And, they all refer to a single active group object of the NavBarGroup type.