Questo argomento non è stato ancora valutato - Valuta questo argomento

Classe TreeView

Represents a control that displays hierarchical data in a tree structure that has items that can expand and collapse.

Spazio dei nomi: System.Windows.Controls
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

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.

TreeView illustration

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.

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Control
               System.Windows.Controls.ItemsControl
                System.Windows.Controls.TreeView
I membri statici pubblici (Shared in Visual Basic) di questo tipo sono validi per le operazioni multithreading. I membri di istanza non sono garantiti come thread safe.

Microsoft .NET Framework 3.0 è supportato in Windows Vista, Microsoft Windows XP SP2 e Windows Server 2003 SP1.

.NET Framework

Supportato in:
Il documento è risultato utile?
(1500 caratteri rimanenti)

Aggiunte alla community

AGGIUNGI
© 2013 Microsoft. Tutti i diritti riservati.