# Hierarchical Data Binding

This article shows how to data bind hierarchical data to RadNavigationView.

The control can be populated with business objects via its **ItemsSource** property. Then the **DisplayMemberPath** and **ItemContainerStyle** properties can be used to further customize the items and allow sub-items.

## Defining the Model

The following model is defining a string property to serve as the content of the items and a collection for the child data items. An additional string property is used for the icon [glyph](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/glyphs/common-styles-appearance-glyphs-overview).

**Example 1: Creating the model**

```C#
public class NavigationItemModel
{
    public string Title { get; set; }
    public string IconGlyph { get; set; }
    public ObservableCollection<NavigationItemModel> Children { get; set; }
}
```

**Example 2: Populating the collection with data**

```C#
public void PopulateWithItems()
{
    var source = new ObservableCollection<NavigationItemModel>()
    {
        new NavigationItemModel()
        {
            Title = "Accounts",
            IconGlyph = "&#xe81b;",
            Children = new ObservableCollection<NavigationItemModel>()
            {
                new NavigationItemModel() { Title = "Martin Ivanov (mi@prgs.com)", IconGlyph = "&#xe801;" },
                new NavigationItemModel() { Title = "Jon Doe (jd@prgs.com)", IconGlyph = "&#xe801;" },
            }
        },
        new NavigationItemModel()
        {
            Title = "Folders",
            IconGlyph = "&#xe900;",
            Children = new ObservableCollection<NavigationItemModel>()
            {
                new NavigationItemModel() { Title = "Inbox", IconGlyph = "&#xe802;" },
                new NavigationItemModel() { Title = "Drafts", IconGlyph = "&#xe906;" },
                new NavigationItemModel() { Title = "Sent Items", IconGlyph = "&#xe101;" },
                new NavigationItemModel() { Title = "Deleted Items", IconGlyph = "&#xe10c;" },
            }
        }
    };

    this.DataContext = source;
}
```

## Defining the View

To assign the data collection to the RadNavigationView control, set its **ItemsSource** property.

To data bind the content of the RadNavigationViewItem elements set the **DisplayMemberPath** property of RadNavigationView. Alternatively, you can use the **ItemContainerStyle** and set the **Content** property of the RadNavigationViewItems.

To customize the appearance of the RadNavigationViewItems and also allow sub-items to be shown, use an implicit style. This allows to set the **ItemsSource**  and **DisplayMemberPath** properties of the **RadNavigationViewItems**.

**Example 3: Setting up the view**

```XAML
<telerik:RadNavigationView x:Name="radNavigationView" 
							   ItemsSource="{Binding}" 
							   PaneHeader="Header"
							   DisplayMemberPath="Title"
							   DisplayMode="Expanded">
    <telerik:RadNavigationView.Resources>
        <telerik:StringToGlyphConverter x:Key="StringToGlyphConverter" />
        
        <Style TargetType="telerik:RadNavigationViewItem">
            <Setter Property="ItemsSource" Value="{Binding Children}" />
            <Setter Property="DisplayMemberPath" Value="Title" />
            <Setter Property="Icon" Value="{Binding IconGlyph}" />
            <Setter Property="IconTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <telerik:RadGlyph Glyph="{Binding Converter={StaticResource StringToGlyphConverter}}" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </telerik:RadNavigationView.Resources>
    <telerik:RadNavigationView.Content>
        <ContentControl Content="{Binding SelectedItem, ElementName=radNavigationView}">
            <ContentControl.ContentTemplate>
                <DataTemplate>
                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Title}" />
                </DataTemplate>
            </ContentControl.ContentTemplate>
        </ContentControl>
    </telerik:RadNavigationView.Content>
</telerik:RadNavigationView>
```

> caption RadNavigationView with sub items

![WPF RadNavigationView RadNavigationView with sub items](https://www.telerik.com/products/wpf/documentation/assets/a9613d58c3a6821edf56ec1bac4771c1/radnavigationview-populating-with-data-hierarchical-databinding-0.png)

Note that for every business object from the data bound collection, RadNavigationView will generate a RadNavigationViewItem container representing this object.

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/getting-started)
* [Data Binding](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/populating-with-data/databinding)
* [Display Mode](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/features/display-mode)
