TreeView Class
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
[StyleTypedPropertyAttribute(Property=L"ItemContainerStyle", StyleTargetType=typeof(TreeViewItem))] public ref class TreeView : public ItemsControl
/** @attribute StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=System.Windows.Controls.TreeViewItem) */ public class TreeView extends ItemsControl
StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=System.Windows.Controls.TreeViewItem) public class TreeView extends ItemsControl
<TreeView> Items </TreeView>
Content Model: TreeView is an ItemsControl and has two content properties: Items and ItemsSource. For information about how to set these properties, see the Items Control Content Model overview.
The following illustration shows a simple TreeView.
The contents of a TreeView are TreeViewItem controls that can contain rich content, such as Button and Image controls. A TreeViewItem can contain one or more TreeViewItem objects as its descendants. A TreeView is defined as a hierarchy of TreeViewItem objects.
A TreeView can populate its tree by binding to a data source and using HierarchicalDataTemplate objects. Examples of data sources include XmlDataProvider and ObservableCollection objects. For an example, see Hierarchical Data Template Sample.
For more information about the TreeView control, see the TreeView Overview.
The following example shows how to create a TreeView.
<TreeView> <TreeViewItem Header="Employee1"> <TreeViewItem Header="Jesper"/> <TreeViewItem Header="Aaberg"/> <TreeViewItem Header="12345"/> </TreeViewItem> <TreeViewItem Header="Employee2"> <TreeViewItem Header="Dominik"/> <TreeViewItem Header="Paiha"/> <TreeViewItem Header="98765"/> </TreeViewItem> </TreeView>
HOWDOI#ds_task_hierarchicaldatatemplate
More Code
| How to: Create Simple or Complex TreeViews | This example shows how to create simple or complex TreeView controls. |
| How to: Use SelectedValue, SelectedValuePath, and SelectedItem | This example shows how to use the SelectedValue and SelectedValuePath properties to specify a value for the SelectedItem of a TreeView. |
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.