Classe TreeView
Assembly: PresentationFramework (in presentationframework.dll)
Spazio dei nomi XML: http://schemas.microsoft.com/winfx/2006/xaml/presentation
[StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=typeof(TreeViewItem))] public class TreeView : 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
Altro codice
| 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. |