The XAML TreeView element represents a TreeView control in WPF. The code in this article are examples of using a XAML TreeView element.
XAML TreeView element to declare the TreeView control.
- <TreeView Margin="10,10,0,13" Name="TreeView1" HorizontalAlignment="Left"
- VerticalAlignment="Top" Width="194" Height="200" />
A TreeView is a collection of TreeViewItem elements. The following XAML code adds a few TreeViewItem element to the control.
- <TreeView Margin="10,10,0,13" Name="TreeView1" HorizontalAlignment="Left"
- VerticalAlignment="Top" Width="194" Height="200">
- <TreeViewItem Header="Cold Drinks">
- <TreeViewItem Header="Coke"></TreeViewItem>
- <TreeViewItem Header="Pepsi"></TreeViewItem>
- <TreeViewItem Header="Orange Juice"></TreeViewItem>
- <TreeViewItem Header="Milk"></TreeViewItem>
- <TreeViewItem Header="Iced Tea"></TreeViewItem>
- <TreeViewItem Header="Mango Shake"></TreeViewItem>
- </TreeViewItem>
- </TreeView>
You can write a double click event handler on a TreeViewItem to execute some code when a TreeView item is double clicked.
- <TreeViewItem Header="Dad" Foreground="Blue" MouseDoubleClick="TreeViewItem_MouseDoubleClick">
- private void TreeViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- }

abdul qadirPosted Dec 12, 2018, 12:41 AM
How can i get treeviewitem to textbox on mouse duble click.
bhuvenPosted Aug 18, 2015, 5:50 AM
Please help. I setup a TreeView with TreeViewItems using above guide. When user click on slecetion, I want to open a screen for input. Please advise as ri how I can achieve this. Many thanks