Skip to main content
A newer version of this page is available. .

Item Content Model

  • 2 minutes to read

This topic describes how the item content can be defined using specific properties, and how an item (that is a content element) is referred to within the visual tree.

Item Content

The content of an item can be defined by using the NavBarItem.Content property. This property is of type Object, so you can provide any custom content for an item - there are no restrictions on what you can put in item content.

Note

The NavBarItem.Content property is, by design, specified as the default property and the content property of an item. This, for example, allows you to declare item contents in XAML directly after an item declaration, without wrapping them into opening and closing NavBarItem.Content tags.

Item Image

You can use the NavBarItem.ImageSource property to associate an item with an image that will be displayed within the item to visually indicate it.

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

<dxn:NavBarControl Name="navBarControl1" >
    <dxn:NavBarControl.Groups>

        <dxn:NavBarGroup Header="Group1">
            <dxn:NavBarItem Content="Item1" ImageSource="/MyProject;component/Images/image1.png"/>
            <dxn:NavBarItem>
                <dxn:NavBarItem.Content>Item2</dxn:NavBarItem.Content>
            </dxn:NavBarItem>
            <dxn:NavBarItem>Item3</dxn:NavBarItem>
        </dxn:NavBarGroup>

    </dxn:NavBarControl.Groups>

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

Items in Visual Tree

DXNavBar items (represented by NavBarItem 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 NavBarItemControl type represents an item in the visual tree, and serves as a content host for the item.