TreeView And TreeViewItem : TreeView « Windows Presentation Foundation « C# / C Sharp






TreeView And TreeViewItem

TreeView And TreeViewItem
   

<Window x:Class="SimpleStyles.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="SimpleStyles"
  Background="#F8F8F8">
  <ScrollViewer>
    <WrapPanel>
       <HeaderedItemsControl Header="TreeView">
        <StackPanel>
          <TreeView Width="150" Height="150" Margin="8">
            <TreeViewItem Header="Top One">
              <TreeViewItem Header="Sub One" />
              <TreeViewItem Header="Sub Two (Longer than Normal)" />
              <TreeViewItem Header="Sub Three" />
              <TreeViewItem Header="Sub Four">
                <TreeViewItem Header="Sub One" />
                <TreeViewItem Header="Sub Two" />
                <TreeViewItem Header="Sub Three" />
              </TreeViewItem>
              <TreeViewItem Header="Sub Five" />
            </TreeViewItem>
            <TreeViewItem Header="Top Two">
              <TreeViewItem Header="Sub One" />
              <TreeViewItem Header="Checkable" />
              <TreeViewItem Header="Sub Three" />
              <TreeViewItem Header="Sub Four">
                <TreeViewItem Header="Sub One" />
                <TreeViewItem Header="Sub Two" />
                <TreeViewItem Header="Sub Three" />
              </TreeViewItem>
              <TreeViewItem Header="Sub Five" />
            </TreeViewItem>
            <TreeViewItem Header="Top Three" >
              <TreeViewItem Header="Sub One" />
              <TreeViewItem Header="Sub Two" />
              <TreeViewItem Header="Sub Three" />
              <TreeViewItem Header="Sub Five" />
            </TreeViewItem>
          </TreeView>
        </StackPanel>
      </HeaderedItemsControl>
   
    </WrapPanel>
  </ScrollViewer>
</Window>

   
    
    
  








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.Create a Tree and add childrenCreate a Tree and add children
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