# Hierarchy

RadNavigationView allows you to define sub-items in order to achieve hierarchical menu visualization.

Each RadNavigationViewItem element has an Items collection that can be populated with RadNavigationViewItem elements, thus allowing multiple levels of items to be defined in the hierarchy.

**Setting up hierarchical navigation view in XAML**

```XAML
<telerik:RadNavigationView PaneHeader="Mail">
    <telerik:RadNavigationView.Items>
        <telerik:RadNavigationViewItem Content="Accounts">
            <telerik:RadNavigationViewItem.Items>
                <telerik:RadNavigationViewItem Content="Martin Ivanov (mi@prgs.com)" />
                <telerik:RadNavigationViewItem Content="Jon Doe (jd@prgs.com)" />
            </telerik:RadNavigationViewItem.Items>
        </telerik:RadNavigationViewItem>
        <telerik:RadNavigationViewItem Content="Folders">
            <telerik:RadNavigationViewItem.Items>
                <telerik:RadNavigationViewItem Content="Inbox"/>
                <telerik:RadNavigationViewItem Content="Drafts"/>
                <telerik:RadNavigationViewItem Content="Sent Items"/>
                <telerik:RadNavigationViewItem Content="Deleted Items"/>
            </telerik:RadNavigationViewItem.Items>
        </telerik:RadNavigationViewItem>
    </telerik:RadNavigationView.Items>
</telerik:RadNavigationView>
```

To control the current expand state of a RadNavigationViewItem, set its **IsExpanded** property.

> caption Hierarchical RadNavigationView

![RadNavigationView Hierarchical RadNavigationView](https://www.telerik.com/products/wpf/documentation/assets/11932a1b506dedfdd91f9cf4122bc929/radnavigationview-features-hierarchy-0.png)

## Multiple Expanded Items

By default, multiple RadNavigationViewItem elements with child items can be expanded at once. To change this and allow only a single expanded item, set the `AllowMultipleExpandedItems` property of RadNavigationView to False.

**Disabling multiple expanded items at once**

```XAML
<telerik:RadNavigationView AllowMultipleExpandedItems="False" />
```

## Child Items Indentation

To change the default horizontal offset (indent) of the child items relative to their parent, set the `SubItemsIndentation` property of RadNavigationView.

**Setting the indent of sub items**

```XAML
<telerik:RadNavigationView SubItemsIndentation="10" />
```

> caption Sub items indentation set to 10

![RadNavigationView Sub items indentation set to 10](https://www.telerik.com/products/wpf/documentation/assets/df3628bba50c0457c119b874620ce967/radnavigationview-features-hierarchy-1.png)

## Expand and Collapse Icon

RadNavigationViewItem has default expand and collapse icons shown in the right part of the item when it has children. To replace the icons, set the `ExpandedIcon` and `CollapsedIcon` properties of RadNavigationViewItem. The default icon template uses [RadGlyph](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/glyphs/common-styles-appearance-glyphs-radglyph) and you can set the properties to a glyph string from the [glyphs reference sheet](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/glyphs/common-styles-appearance-glyphs-reference-sheet).

**Setting the expand and collapse icons**

```XAML
<telerik:RadNavigationViewItem ExpandedIcon="&#xe901;" CollapsedIcon="&#xe900;"/>
```

> caption RadNaviationViewItems with folder glyphs as expand/collapse icons

![RadNavigationView RadNaviationViewItems with folder glyphs as expand/collapse icons](https://www.telerik.com/products/wpf/documentation/assets/cea6e2f4d2235db4afcb84536c99034e/radnavigationview-features-hierarchy-2.png)

To change this behavior and use other UI for the icons like a customized RadGlyph, an Image, or any other element, set the `ExpandedIconTemplate` and `CollapsedIconTemplate` properties. The properties expect DataTemplate values.

**Setting the expand and collapse icon templates**

```XAML
<Grid.Resources>
    <DataTemplate x:Key="ExpandedCollapsedIconTemplate">
        <Image Source="{Binding}" Width="16" Height="16" />
    </DataTemplate>
</Grid.Resources>

<telerik:RadNavigationViewItem ExpandedIcon="Images/expanded-icon.png" 
                           CollapsedIcon="Images/collapsed-icon.png" 
                           ExpandedIconTemplate="{StaticResource ExpandedCollapsedIconTemplate}"
                           CollapsedIconTemplate="{StaticResource ExpandedCollapsedIconTemplate}" />
```

> caption RadNavigationViewItems with folder images as expand/collapse icons

![RadNavigationView RadNavigationViewItems with folder images as expand/collapse icons](https://www.telerik.com/products/wpf/documentation/assets/b6cf88b14ce71d3b55160aa00cfc4b69/radnavigationview-features-hierarchy-3.png)

In data binding scenarios or when there are many items, you can use the `ItemContainerStyle` property to set the icon properties.

## Limiting the Height of Child Items

The `NavigationViewSubItemsHost` for a child `RadNavigationViewItem` is generated by the item control template as the `PART_NavigationViewSubItemsHost` template part. To limit the height of one generated child items host, provide a custom `RadNavigationViewItem` template based on the active theme template and set `MaxHeight` on this template part. The `RadNavigationViewItem` API does not expose a property that sets the maximum height of this generated host directly.

## Flyout

When RadNavigationView is collapsed and its current [DisplayMode](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/features/display-mode) Compact, you can display the nested menu items by clicking on the collapsed RadNavigationViewItems.

> caption Sub menu flyout visualization

![RadNavigationView Sub menu flyout visualization](https://www.telerik.com/products/wpf/documentation/assets/913d72b0de05113523f4fa51ec9700d4/radnavigationview-features-hierarchy-4.png)

## AllowSingleClickExpandInCompactMode

RadNavigationView exposes the `AllowSingleClickExpandInCompactMode` property. It allows you to choose if the top-level `RadNavigationViewItem` elements can expand with a single click when hosted in a [flyout](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/features/hierarchy#flyout). The default value of the AllowSingleClickExpandInCompactMode property is **True**. If the property is set to false, two clicks will need to be performed, in order to open a different top-level RadNavigationViewItem element.

**Setting the AllowSingleClickExpandInCompactMode property**

```XAML
<telerik:RadNavigationView PaneHeader="Mail"
	                           DisplayMode="Compact" 
	                           AllowSingleClickExpandInCompactMode="False">
    <telerik:RadNavigationView.Items>
        <telerik:RadNavigationViewItem Content="Accounts">
            <telerik:RadNavigationViewItem.Items>
                <telerik:RadNavigationViewItem Content="Martin Ivanov (mi@prgs.com)"/>
                <telerik:RadNavigationViewItem Content="Stenly Grigorov (sg@prgs.com)"/>
            </telerik:RadNavigationViewItem.Items>
        </telerik:RadNavigationViewItem>
        <telerik:RadNavigationViewItem Content="Folders">
            <telerik:RadNavigationViewItem.Items>
                <telerik:RadNavigationViewItem Content="Inbox"/>
                <telerik:RadNavigationViewItem Content="Drafts"/>
                <telerik:RadNavigationViewItem Content="Sent Items"/>
                <telerik:RadNavigationViewItem Content="Deleted Items"/>
            </telerik:RadNavigationViewItem.Items>
        </telerik:RadNavigationViewItem>
    </telerik:RadNavigationView.Items>
</telerik:RadNavigationView>
```

> caption RadNavigationView with two clicks to open a different top-level RadNavigationViewItem element

![RadNavigationView with two clicks to open a different top-level RadNavigationViewItem element](https://www.telerik.com/products/wpf/documentation/assets/6da378e2109800cb1d68472ee1834dfa/radnavigationview-features-hierarchy-5.gif)

## Events

The expanding and collapsing actions fire the `ItemExpanded` and `ItemCollapsed` events of RadNavigationView.

Additionally, the RadNavigationViewItem exposes `Expanded` and `Collapsed` events.

**Subscribing to ItemExpanded event**

```XAML
<telerik:RadNavigationView ItemExpanded="RadNavigationView_ItemExpanded" />
```

**ItemExpanded event handler**

```C#
private void RadNavigationView_ItemExpanded(object sender, RoutedEventArgs e)
{
    var expandedItem = (RadNavigationViewItem)e.OriginalSource;
}
```

> The Expanded/Collapsed event of RadNavigationViewItem is fired before the ItemExpanded/ItemCollapsed event of RadNavigationView.

## Data Binding

RadNavigationViewItem exposes ItemsSource and few other data related properties that allow setting up the hierarchy in a data binding scenario. Read more about this in the [Hierarchical Data Binding](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/populating-with-data/hierarchical-databinding) article.

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/getting-started)
* [Display Mode](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/features/display-mode)
* [Events](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/events)
* [Icon and IconTemplate](https://www.telerik.com/products/wpf/documentation/controls/radnavigationview/features/icon-and-icontemplate)
