Class TreeView
Represents a control that displays hierarchical data in a tree structure that has items that can expand and collapse.
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
[StyleTypedProperty(Property = "ItemContainerStyle", StyleTargetType = typeof(TreeViewItem))]
public class TreeView : ItemsControl
Constructors
| Improve this Doc View SourceTreeView()
Initializes a new instance of the TreeView class.
Declaration
public TreeView()
Fields
| Improve this Doc View SourceItemContainerStyleProperty
Identifies the ItemContainerStyle dependency property.
Declaration
public static readonly DependencyProperty ItemContainerStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the ItemContainerStyle dependency property. |
SelectedItemProperty
Identifies the SelectedItem dependency property.
Declaration
public static readonly DependencyProperty SelectedItemProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SelectedItem property. |
SelectedValuePathProperty
Identifies the SelectedValuePath dependency property.
Declaration
public static readonly DependencyProperty SelectedValuePathProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SelectedValuePath dependency property. |
SelectedValueProperty
Identifies the SelectedValue dependency property.
Declaration
public static readonly DependencyProperty SelectedValueProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SelectedValue dependency property. |
Properties
| Improve this Doc View SourceItemContainerStyle
Gets or sets the Style that is applied to the container element generated for each item.
Declaration
public Style ItemContainerStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The Style applied to the container element that contains each item. |
SelectedItem
Gets the selected item in a TreeView.
Declaration
public object SelectedItem { get; }
Property Value
Type | Description |
---|---|
System.Object | The currently selected item or null if no item is selected. The default value is null. |
SelectedValue
Gets the value of the SelectedItem property that is specified by the SelectedValuePath property.
Declaration
public object SelectedValue { get; }
Property Value
Type | Description |
---|---|
System.Object | The value of the SelectedItem property that is specified by the SelectedValuePath property, or null if no item is selected. The default value is null. |
SelectedValuePath
Gets or sets the property path that is used to get the SelectedValue property of the SelectedItem property in a TreeView.
Declaration
public string SelectedValuePath { get; set; }
Property Value
Type | Description |
---|---|
System.String | The property path that is used to get the SelectedValue property of the SelectedItem property in a TreeView. The default value is System.String.Empty. |
Methods
| Improve this Doc View SourceClearContainerForItemOverride(DependencyObject, Object)
Removes all templates, styles, and bindings for the object displayed as a TreeViewItem.
Declaration
protected override void ClearContainerForItemOverride(DependencyObject element, object item)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The TreeViewItem element to clear. |
System.Object | item | The item that is contained in the TreeViewItem. |
Overrides
| Improve this Doc View SourceGetContainerForItemOverride()
Creates a TreeViewItem to display content.
Declaration
protected override DependencyObject GetContainerForItemOverride()
Returns
Type | Description |
---|---|
DependencyObject | A TreeViewItem to use as a container for content. |
Overrides
| Improve this Doc View SourceIsItemItsOwnContainerOverride(Object)
Determines whether the specified item is a TreeViewItem, which is the default container for items in the TreeView control.
Declaration
protected override bool IsItemItsOwnContainerOverride(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item | The object to evaluate. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item is a TreeViewItem; otherwise, false. |
Overrides
| Improve this Doc View SourceOnApplyTemplate()
Builds the visual tree for the TreeView control when a new control template is applied.
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnCreateAutomationPeer()
Returns a TreeViewAutomationPeer for use by the Silverlight automation infrastructure.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
AutomationPeer | A TreeViewAutomationPeer for the TreeView control. |
Overrides
| Improve this Doc View SourceOnGotFocus(RoutedEventArgs)
Provides handling for the GotFocus event.
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | Event arguments. |
Overrides
| Improve this Doc View SourceOnItemsChanged(NotifyCollectionChangedEventArgs)
Declaration
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.NotifyCollectionChangedEventArgs | e | A System.Collections.Specialized.NotifyCollectionChangedEventArgs that contains data about the change. |
Overrides
| Improve this Doc View SourceOnKeyDown(KeyEventArgs)
Provides handling for the KeyDown event when a key is pressed while the control has focus.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | A KeyEventArgs that contains the event data. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
OnKeyUp(KeyEventArgs)
Provides handling for the KeyUp event.
Declaration
protected override void OnKeyUp(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | Event arguments. |
Overrides
| Improve this Doc View SourceOnLostFocus(RoutedEventArgs)
Provides handling for the LostFocus event.
Declaration
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | Event arguments. |
Overrides
| Improve this Doc View SourceOnMouseEnter(MouseEventArgs)
Provides handling for the MouseEnter event.
Declaration
protected override void OnMouseEnter(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | e | Event arguments. |
Overrides
| Improve this Doc View SourceOnMouseLeave(MouseEventArgs)
Provides handling for the MouseLeave event.
Declaration
protected override void OnMouseLeave(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | e | Event arguments. |
Overrides
| Improve this Doc View SourceOnMouseLeftButtonDown(MouseButtonEventArgs)
Provides handling for the MouseLeftButtonDown event.
Declaration
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseButtonEventArgs | e | A MouseButtonEventArgs that contains the event data. |
Overrides
| Improve this Doc View SourceOnMouseLeftButtonUp(MouseButtonEventArgs)
Provides handling for the MouseLeftButtonUp event.
Declaration
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseButtonEventArgs | e | Event arguments. |
Overrides
| Improve this Doc View SourceOnMouseMove(MouseEventArgs)
Provides handling for the MouseMove event.
Declaration
protected override void OnMouseMove(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | e | Event arguments. |
Overrides
| Improve this Doc View SourceOnSelectedItemChanged(RoutedPropertyChangedEventArgs<Object>)
Raises the SelectedItemChanged event when the SelectedItem property value changes.
Declaration
protected virtual void OnSelectedItemChanged(RoutedPropertyChangedEventArgs<object> e)
Parameters
Type | Name | Description |
---|---|---|
RoutedPropertyChangedEventArgs<System.Object> | e | A RoutedPropertyChangedEventArgs<T> that contains the event data. |
PrepareContainerForItemOverride(DependencyObject, Object)
Prepares the container element to display the specified item.
Declaration
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The container element used to display the specified item. |
System.Object | item | The item to display. |
Overrides
Events
| Improve this Doc View SourceSelectedItemChanged
Occurs when the value of the SelectedItem property changes.
Declaration
public event RoutedPropertyChangedEventHandler<object> SelectedItemChanged
Event Type
Type | Description |
---|---|
RoutedPropertyChangedEventHandler<System.Object> |