Create a Tree and add children : TreeView « Windows Presentation Foundation « C# / C Sharp






Create a Tree and add children

Create a Tree and add children
    

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      HorizontalAlignment="Center" VerticalAlignment="Center">

<TreeView>
  <TreeViewItem Header="A" IsExpanded="True">
    <TreeViewItem Header="B" />
    <TreeViewItem Header="C" IsExpanded="True">
      <TreeViewItem Header="D" />
      <TreeViewItem Header="E" />
    </TreeViewItem>
    <TreeViewItem Header="F" />
  </TreeViewItem>
  <TreeViewItem Header="G">
    <TreeViewItem Header="Child a" />
    <TreeViewItem Header="Child b" />
    <TreeViewItem Header="Child c" />
  </TreeViewItem>
</TreeView>
</Page>

   
    
    
    
  








Related examples in the same category

1.TreeView uses SelectedValuePath property to provide a SelectedValue for the SelectedItem.TreeView uses SelectedValuePath property to provide a SelectedValue for the SelectedItem.
2.TreeView with DataSourceTreeView with DataSource
3.TreeView And TreeViewItemTreeView And TreeViewItem
4.Add Ellipse, TextBlock to a TreeAdd Ellipse, TextBlock to a Tree
5.Mark Tree node expandableMark Tree node expandable
6.Bind a TreeView to a data source and use DataTemplate objects to customize the TreeView.Bind a TreeView to a data source and use DataTemplate objects to customize the TreeView.
7.Handles the Selected event for all TreeViewItemsHandles the Selected event for all TreeViewItems
8.Set TreeView with TreeViewItemSet TreeView with TreeViewItem
9.View and Select Items Using a TreeView and Select Items Using a Tree
10.Get selected tree node itemGet selected tree node item