Class TreeViewItem
Provides a selectable item for the TreeView control.
Inheritance
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
[TemplatePart(Name = "ExpanderButton", Type = typeof(ToggleButton))]
[TemplatePart(Name = "Header", Type = typeof(FrameworkElement))]
[StyleTypedProperty(Property = "ItemContainerStyle", StyleTargetType = typeof(TreeViewItem))]
public class TreeViewItem : HeaderedItemsControl
Constructors
| Improve this Doc View SourceTreeViewItem()
Initializes a new instance of the TreeViewItem class.
Declaration
public TreeViewItem()
Fields
| Improve this Doc View SourceHasItemsProperty
Identifies the HasItems dependency property.
Declaration
public static readonly DependencyProperty HasItemsProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the HasItems dependency property. |
IsExpandedProperty
Identifies the IsExpanded dependency property.
Declaration
public static readonly DependencyProperty IsExpandedProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the IsExpanded dependency property. |
IsSelectedProperty
Identifies the IsSelected dependency property.
Declaration
public static readonly DependencyProperty IsSelectedProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the IsSelected dependency property. |
IsSelectionActiveProperty
Identifies the IsSelectionActive dependency property.
Declaration
public static readonly DependencyProperty IsSelectionActiveProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the IsSelectionActive dependency property. |
Properties
| Improve this Doc View SourceHasItems
Gets a value indicating whether this TreeViewItem contains items.
Declaration
public bool HasItems { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if this TreeViewItem contains items; otherwise, false. The default is false. |
IsExpanded
Gets or sets a value indicating whether the Items contained by this TreeViewItem are expanded or collapsed.
Declaration
public bool IsExpanded { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True to indicate the contents of the Items collection are expanded; false to indicate the items are collapsed. The default is false. |
IsSelected
Gets or sets a value indicating whether this TreeViewItem is selected.
Declaration
public bool IsSelected { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if this TreeViewItem is selected; otherwise, false. The default is false. |
IsSelectionActive
Gets a value indicating whether the TreeViewItem has focus.
Declaration
public bool IsSelectionActive { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if this TreeViewItem has focus; otherwise, false. The default is false. |
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 an object is a TreeViewItem.
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 |
Overrides
| Improve this Doc View SourceOnApplyTemplate()
Builds the visual tree for the TreeViewItem control when a new control template is applied.
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnCollapsed(RoutedEventArgs)
Raises a Collapsed event when the IsExpanded property changes from true to false.
Declaration
protected virtual void OnCollapsed(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains the event data. |
OnCreateAutomationPeer()
Returns a TreeViewItemAutomationPeer for use by the Silverlight automation infrastructure.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
AutomationPeer | A TreeViewItemAutomationPeer object for the TreeViewItem. |
Overrides
| Improve this Doc View SourceOnExpanded(RoutedEventArgs)
Raises an Expanded event when the IsExpanded property changes from false to true.
Declaration
protected virtual void OnExpanded(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains the event data. |
OnGotFocus(RoutedEventArgs)
Provides handling for the GotFocus event.
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains the event data. |
Overrides
| Improve this Doc View SourceOnItemsChanged(NotifyCollectionChangedEventArgs)
Makes adjustments to the TreeViewItem when the value of the Items property changes.
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 the TreeViewItem has focus.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | A KeyEventArgs that contains the event data. |
Overrides
| Improve this Doc View SourceOnKeyUp(KeyEventArgs)
Provides handling for the KeyUp event.
Declaration
protected override void OnKeyUp(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | A KeyEventArgs that contains the event data. |
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 | A RoutedEventArgs that contains the event data. |
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 | A MouseEventArgs that contains the event data. |
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 | A MouseEventArgs that contains the event data. |
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 | A MouseButtonEventArgs that contains the event data. |
Overrides
| Improve this Doc View SourceOnSelected(RoutedEventArgs)
Raises the Selected event when the IsSelected property changes from false to true.
Declaration
protected virtual void OnSelected(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains the event data. |
OnUnselected(RoutedEventArgs)
Raises the Unselected event when the IsSelected property changes from true to false.
Declaration
protected virtual void OnUnselected(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains the event data. |
PrepareContainerForItemOverride(DependencyObject, Object)
Prepares the specified container element to display the specified item.
Declaration
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | Container element used to display the specified item. |
System.Object | item | The item to display. |
Overrides
Events
| Improve this Doc View SourceCollapsed
Occurs when the IsExpanded property changes from true to false.
Declaration
public event RoutedEventHandler Collapsed
Event Type
Type | Description |
---|---|
RoutedEventHandler |
Expanded
Occurs when the IsExpanded property changes from false to true.
Declaration
public event RoutedEventHandler Expanded
Event Type
Type | Description |
---|---|
RoutedEventHandler |
Selected
Occurs when the IsSelected property of a TreeViewItem changes from false to true.
Declaration
public event RoutedEventHandler Selected
Event Type
Type | Description |
---|---|
RoutedEventHandler |
Unselected
Occurs when the IsSelected property of a TreeViewItem changes from true to false.
Declaration
public event RoutedEventHandler Unselected
Event Type
Type | Description |
---|---|
RoutedEventHandler |