RadTreeView allows you to navigate through the nodes without using the mouse. The keyboard can entirely replace the mouse by allowing you to perform navigation, editing, expanding, collapsing and selecting the nodes.
RadTreeView provides first class keyboard support. Here is the list of the keys that are supported:
- ARROW KEYS - navigate in the tree
- PageUp, PageDown - page the RadTreeViewItems in the view port area
- End, Home - go to last/first visible item
- ENTER - if in edit mode - set the new item value, else toggle collapsed/expanded state
- ESC - cancel edit or drag
- MULTIPLY - Expand all child items
- DIVIDE - Collapse all child items
- ADD, SUBSTRACT - expand/collapse selected item
- F2, SPACE - start edit mode
- CTRL, SHIFT - multiple item selection
RadTreeView exposes several useful properties and events, which can help you control the keyboard interaction and get notified when a key is up or down.
Set the IsTabStop property to include/exclude the control in the tab navigation cycle. If this property is set to True, then the control will be included; if it is False then it will be skipped.
- The TabIndex property defines the index of the control in the tab navigation cycle. The lower the number is, the earlier the control will be focused while navigating using the Tab key. If you set this property, do not forget to set IsTabStop to True. Once focused, you can navigate through the tab pages using the left and the right arrow keys.
- KeyDown - Get notofied when the user has pressed a keyboard key.
- KeyUp - Get notified when the user has released a keyboard key.
To obtain the pressed key, the object that raised the event or some other information, use the instance of System.Windows.Input.KeyEventArgs passed as a parameter to the event handler method.
In the example below you can see how to attach to KeyDown and KeyUp events and how to specify a value for the TabNavigation property from your XAML.
<telerik:RadTreeView x:Name="radTreeView" KeyDown="radTreeView_KeyDown" KeyUp="radTreeView_KeyUp"/>
The implementation of both of the event handlers radTreeView_KeyDown and radTreeView_KeyUp is located in the code-behind file (C# or VB.NET) and looks like this:
private void radTreeView_KeyDown( object sender, KeyEventArgs e )
MessageBox.Show( "The pressed key is: " + e.Key.ToString() );
private void radTreeView_KeyUp( object sender, KeyEventArgs e )
MessageBox.Show( "The released key is: " + e.Key.ToString() );
Private Sub radTreeView_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
MessageBox.Show("The pressed key is: " & e.Key.ToString())
Private Sub radTreeView_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs)
MessageBox.Show("The released key is: " & e.Key.ToString())