Show / Hide Table of Contents

Class TreeViewItem

Provides a selectable item for the TreeView control.

Inheritance
System.Object
DependencyObject
UIElement
FrameworkElement
Control
ItemsControl
HeaderedItemsControl
TreeViewItem
Inherited Members
HeaderedItemsControl.Header
HeaderedItemsControl.HeaderProperty
HeaderedItemsControl.HeaderTemplate
HeaderedItemsControl.HeaderTemplateProperty
HeaderedItemsControl.ItemContainerStyle
HeaderedItemsControl.ItemContainerStyleProperty
HeaderedItemsControl.OnHeaderChanged(Object, Object)
HeaderedItemsControl.OnHeaderTemplateChanged(DataTemplate, DataTemplate)
ItemsControl.Items
ItemsControl.ItemContainerGenerator
ItemsControl.ItemsPanel
ItemsControl.ItemsPanelProperty
ItemsControl.ItemsSource
ItemsControl.ItemsSourceProperty
ItemsControl.ItemTemplate
ItemsControl.ItemTemplateProperty
ItemsControl.DisplayMemberPath
ItemsControl.DisplayMemberPathProperty
ItemsControl.UpdateItemsPanel(ItemsPanelTemplate)
ItemsControl.OnItemsSourceChanged(IEnumerable, IEnumerable)
ItemsControl.LogicalChildren
ItemsControl.GetItemsOwner(DependencyObject)
ItemsControl.ItemsControlFromItemContainer(DependencyObject)
ItemsControl.OnTextInput(TextCompositionEventArgs)
Control.EnableBaseControlHandlingOfVisualStates
Control.ManageIsEnabled(Boolean)
Control.Background
Control.BackgroundProperty
Control.BorderBrush
Control.BorderBrushProperty
Control.BorderThickness
Control.BorderThicknessProperty
Control.FontWeight
Control.FontWeightProperty
Control.FontStyle
Control.FontStyleProperty
Control.Foreground
Control.ForegroundProperty
Control.FontFamily
Control.FontFamilyProperty
Control.FontSize
Control.FontSizeProperty
Control.TextDecorations
Control.TextDecorationsProperty
Control.Padding
Control.PaddingProperty
Control.HorizontalContentAlignment
Control.HorizontalContentAlignmentProperty
Control.VerticalContentAlignment
Control.VerticalContentAlignmentProperty
Control.TabIndex
Control.TabIndexProperty
Control.IsTabStop
Control.IsTabStopProperty
Control.TabNavigation
Control.TabNavigationProperty
Control.Template
Control.TemplateProperty
Control.ApplyTemplate()
Control.GetTemplateChild(String)
Control.Focus()
Control.HandlesScrolling
Control.CreateDomElement(Object, Object)
Control.CharacterSpacingProperty
Control.CharacterSpacing
Control.FontStretchProperty
Control.FontStretch
Control.OnDrop(DragEventArgs)
Control.OnDragEnter(DragEventArgs)
Control.OnDragLeave(DragEventArgs)
Control.OnTextInputUpdate(TextCompositionEventArgs)
Control.MeasureOverride(Size)
Control.ArrangeOverride(Size)
FrameworkElement.LayoutUpdated
FrameworkElement.SizeChanged
FrameworkElement.ResourceLookupMode
FrameworkElement.StyleProperty
FrameworkElement.Style
FrameworkElement.DefaultStyleKeyProperty
FrameworkElement.DefaultStyleKey
FrameworkElement.OverridesDefaultStyleProperty
FrameworkElement.OverridesDefaultStyle
FrameworkElement.OnVisualParentChanged(DependencyObject)
FrameworkElement.VisualChildrenCount
FrameworkElement.GetVisualChild(Int32)
FrameworkElement.Parent
FrameworkElement.AddLogicalChild(Object)
FrameworkElement.RemoveLogicalChild(Object)
FrameworkElement.TemplatedParent
FrameworkElement.Resources
FrameworkElement.IsLoaded
FrameworkElement.SetBinding(DependencyProperty, BindingBase)
FrameworkElement.SetBinding(DependencyProperty, Binding)
FrameworkElement.GetBindingExpression(DependencyProperty)
FrameworkElement.Cursor
FrameworkElement.CursorProperty
FrameworkElement.FindName(String)
FrameworkElement.Name
FrameworkElement.NameProperty
FrameworkElement.DataContext
FrameworkElement.DataContextProperty
FrameworkElement.DataContextChanged
FrameworkElement.Triggers
FrameworkElement.FlowDirectionProperty
FrameworkElement.FlowDirection
FrameworkElement.LanguageProperty
FrameworkElement.Language
FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs)
FrameworkElement.Tag
FrameworkElement.TagProperty
FrameworkElement.LoadedEvent
FrameworkElement.Loaded
FrameworkElement.Unloaded
FrameworkElement.BindingValidationError
FrameworkElement.ContextMenuProperty
FrameworkElement.ContextMenu
FrameworkElement.ContextMenuOpening
FrameworkElement.ToolTipProperty
FrameworkElement.ToolTip
FrameworkElement.INTERNAL_OnDetachedFromVisualTree()
FrameworkElement.INTERNAL_OnAttachedToVisualTree()
FrameworkElement.Height
FrameworkElement.HeightProperty
FrameworkElement.Width
FrameworkElement.WidthProperty
FrameworkElement.HorizontalAlignment
FrameworkElement.HorizontalAlignmentProperty
FrameworkElement.VerticalAlignment
FrameworkElement.VerticalAlignmentProperty
FrameworkElement.Margin
FrameworkElement.MarginProperty
FrameworkElement.MinHeight
FrameworkElement.MinHeightProperty
FrameworkElement.MinWidth
FrameworkElement.MinWidthProperty
FrameworkElement.MaxHeight
FrameworkElement.MaxHeightProperty
FrameworkElement.MaxWidth
FrameworkElement.MaxWidthProperty
FrameworkElement.ActualWidthProperty
FrameworkElement.ActualWidth
FrameworkElement.ActualHeightProperty
FrameworkElement.ActualHeight
UIElement.TransformToVisual(UIElement)
UIElement.RenderSize
UIElement.DesiredSize
UIElement.InvalidateMeasure()
UIElement.InvalidateArrange()
UIElement.Measure(Size)
UIElement.Arrange(Rect)
UIElement.UpdateLayout()
UIElement.DragEnter
UIElement.DragLeave
UIElement.Drop
UIElement.DragOver
UIElement.CacheMode
UIElement.CacheModeProperty
UIElement.Projection
UIElement.ProjectionProperty
UIElement.VisualParent
UIElement.AddVisualChild(UIElement)
UIElement.RemoveVisualChild(UIElement)
UIElement.OnVisualChildrenChanged(DependencyObject, DependencyObject)
UIElement.XamlSourcePath
UIElement.ClipToBounds
UIElement.ClipToBoundsProperty
UIElement.ClipProperty
UIElement.Clip
UIElement.IsEnabledProperty
UIElement.IsEnabled
UIElement.IsEnabledChanged
UIElement.EffectProperty
UIElement.Effect
UIElement.RenderTransformProperty
UIElement.RenderTransform
UIElement.RenderTransformOriginProperty
UIElement.RenderTransformOrigin
UIElement.UseLayoutRounding
UIElement.UseLayoutRoundingProperty
UIElement.Visibility
UIElement.VisibilityProperty
UIElement.IsVisibleProperty
UIElement.IsVisible
UIElement.IsVisibleChanged
UIElement.OpacityProperty
UIElement.Opacity
UIElement.OpacityMaskProperty
UIElement.OpacityMask
UIElement.IsHitTestVisible
UIElement.IsHitTestVisibleProperty
UIElement.AllowDrop
UIElement.AllowDropProperty
UIElement.CaptureMouse()
UIElement.IsMouseCaptured
UIElement.ReleaseMouseCapture()
UIElement.AllowScrollOnTouchMove
UIElement.AllowScrollOnTouchMoveProperty
UIElement.AddHandler(RoutedEvent, Delegate, Boolean)
UIElement.RemoveHandler(RoutedEvent, Delegate)
UIElement.MouseMoveEvent
UIElement.MouseMove
UIElement.OnMouseMove(MouseEventArgs)
UIElement.MouseLeftButtonDownEvent
UIElement.MouseLeftButtonDown
UIElement.MouseRightButtonDownEvent
UIElement.MouseRightButtonDown
UIElement.OnMouseRightButtonDown(MouseButtonEventArgs)
UIElement.MouseWheelEvent
UIElement.MouseWheel
UIElement.OnMouseWheel(MouseWheelEventArgs)
UIElement.MouseLeftButtonUpEvent
UIElement.MouseLeftButtonUp
UIElement.MouseEnterEvent
UIElement.MouseEnter
UIElement.MouseLeaveEvent
UIElement.MouseLeave
UIElement.TextInputStartEvent
UIElement.TextInputStart
UIElement.OnTextInputStart(TextCompositionEventArgs)
UIElement.TextInputEvent
UIElement.TextInput
UIElement.TextInputUpdateEvent
UIElement.TextInputUpdate
UIElement.TappedEvent
UIElement.Tapped
UIElement.OnTapped(TappedRoutedEventArgs)
UIElement.MouseRightButtonUpEvent
UIElement.MouseRightButtonUp
UIElement.OnMouseRightButtonUp(MouseButtonEventArgs)
UIElement.KeyDownEvent
UIElement.KeyDown
UIElement.KeyUpEvent
UIElement.KeyUp
UIElement.GotFocusEvent
UIElement.GotFocus
UIElement.LostFocusEvent
UIElement.LostFocus
UIElement.LostMouseCapture
UIElement.OnLostMouseCapture(MouseEventArgs)
UIElement.INTERNAL_AttachToDomEvents()
UIElement.INTERNAL_DetachFromDomEvents()
DependencyObject.GetValue(DependencyProperty)
DependencyObject.SetCurrentValue(DependencyProperty, Object)
DependencyObject.ReadLocalValue(DependencyProperty)
DependencyObject.SetValue(DependencyProperty, Object)
DependencyObject.SetValue(DependencyPropertyKey, Object)
DependencyObject.CoerceValue(DependencyProperty)
DependencyObject.Dispatcher
DependencyObject.ClearValue(DependencyProperty)
DependencyObject.ClearValue(DependencyPropertyKey)
DependencyObject.CheckAccess()
DependencyObject.GetAnimationBaseValue(DependencyProperty)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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, IControl, IFrameworkElement, IUIElement, IDependencyObject

Constructors

| Improve this Doc View Source

TreeViewItem()

Initializes a new instance of the TreeViewItem class.

Declaration
public TreeViewItem()

Fields

| Improve this Doc View Source

HasItemsProperty

Identifies the HasItems dependency property.

Declaration
public static readonly DependencyProperty HasItemsProperty
Field Value
Type Description
DependencyProperty

The identifier for the HasItems dependency property.

| Improve this Doc View Source

IsExpandedProperty

Identifies the IsExpanded dependency property.

Declaration
public static readonly DependencyProperty IsExpandedProperty
Field Value
Type Description
DependencyProperty

The identifier for the IsExpanded dependency property.

| Improve this Doc View Source

IsSelectedProperty

Identifies the IsSelected dependency property.

Declaration
public static readonly DependencyProperty IsSelectedProperty
Field Value
Type Description
DependencyProperty

The identifier for the IsSelected dependency property.

| Improve this Doc View Source

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 Source

HasItems

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

ClearContainerForItemOverride(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
ItemsControl.ClearContainerForItemOverride(DependencyObject, Object)
| Improve this Doc View Source

GetContainerForItemOverride()

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
ItemsControl.GetContainerForItemOverride()
| Improve this Doc View Source

IsItemItsOwnContainerOverride(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 item is a TreeViewItem; otherwise, false.

Overrides
ItemsControl.IsItemItsOwnContainerOverride(Object)
| Improve this Doc View Source

OnApplyTemplate()

Builds the visual tree for the TreeViewItem control when a new control template is applied.

Declaration
public override void OnApplyTemplate()
Overrides
Control.OnApplyTemplate()
| Improve this Doc View Source

OnCollapsed(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.

| Improve this Doc View Source

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
UIElement.OnCreateAutomationPeer()
| Improve this Doc View Source

OnExpanded(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.

| Improve this Doc View Source

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
Control.OnGotFocus(RoutedEventArgs)
| Improve this Doc View Source

OnItemsChanged(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
ItemsControl.OnItemsChanged(NotifyCollectionChangedEventArgs)
| Improve this Doc View Source

OnKeyDown(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
UIElement.OnKeyDown(KeyEventArgs)
| Improve this Doc View Source

OnKeyUp(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
UIElement.OnKeyUp(KeyEventArgs)
| Improve this Doc View Source

OnLostFocus(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
Control.OnLostFocus(RoutedEventArgs)
| Improve this Doc View Source

OnMouseEnter(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
UIElement.OnMouseEnter(MouseEventArgs)
| Improve this Doc View Source

OnMouseLeave(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
UIElement.OnMouseLeave(MouseEventArgs)
| Improve this Doc View Source

OnMouseLeftButtonDown(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
UIElement.OnMouseLeftButtonDown(MouseButtonEventArgs)
| Improve this Doc View Source

OnMouseLeftButtonUp(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
UIElement.OnMouseLeftButtonUp(MouseButtonEventArgs)
| Improve this Doc View Source

OnSelected(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
HeaderedItemsControl.PrepareContainerForItemOverride(DependencyObject, Object)

Events

| Improve this Doc View Source

Collapsed

Occurs when the IsExpanded property changes from true to false.

Declaration
public event RoutedEventHandler Collapsed
Event Type
Type Description
RoutedEventHandler
| Improve this Doc View Source

Expanded

Occurs when the IsExpanded property changes from false to true.

Declaration
public event RoutedEventHandler Expanded
Event Type
Type Description
RoutedEventHandler
| Improve this Doc View Source

Selected

Occurs when the IsSelected property of a TreeViewItem changes from false to true.

Declaration
public event RoutedEventHandler Selected
Event Type
Type Description
RoutedEventHandler
| Improve this Doc View Source

Unselected

Occurs when the IsSelected property of a TreeViewItem changes from true to false.

Declaration
public event RoutedEventHandler Unselected
Event Type
Type Description
RoutedEventHandler

Extension Methods

DependencyObjectHelper.GetSelfAndAncestors(DependencyObject)
UIElementExtendedRoutedEventExtensions.AddHandler(UIElement, ExtendedRoutedEvent, Delegate, Boolean)
UIElementExtendedRoutedEventExtensions.RemoveHandler(UIElement, ExtendedRoutedEvent, Delegate)
ItemsControlExtensions.GetItemsHost(ItemsControl)
ItemsControlExtensions.GetScrollHost(ItemsControl)
ItemsControlExtensions.GetContainers(ItemsControl)
ItemsControlExtensions.GetContainers<TContainer>(ItemsControl)
ItemsControlExtensions.GetItemsAndContainers(ItemsControl)
ItemsControlExtensions.GetItemsAndContainers<TContainer>(ItemsControl)
TreeViewExtensions.GetParentTreeViewItem(TreeViewItem)
TreeViewExtensions.GetParentTreeView(TreeViewItem)
TreeViewExtensions.GetContainers(TreeViewItem)
TreeViewExtensions.GetItemsAndContainers(TreeViewItem)
TreeViewExtensions.GetDescendantContainers(TreeViewItem)
TreeViewExtensions.GetDescendantItemsAndContainers(TreeViewItem)
TreeViewExtensions.GetSiblingItemsAndContainers(TreeViewItem)
TreeViewExtensions.GetPath(TreeViewItem)
TreeViewExtensions.GetItem(TreeViewItem)
TreeViewExtensions.GetIsRoot(TreeViewItem)
TreeViewExtensions.GetIsLeaf(TreeViewItem)
TreeViewExtensions.GetDepth(TreeViewItem)
TreeViewExtensions.ExpandPath(TreeViewItem)
TreeViewExtensions.GetIsChecked(TreeViewItem)
TreeViewExtensions.SetIsChecked(TreeViewItem, Nullable<Boolean>)
VisualTreeExtensions.GetVisualAncestors(DependencyObject)
VisualTreeExtensions.GetVisualAncestorsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualChildren(DependencyObject)
VisualTreeExtensions.GetVisualChildrenAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualDescendants(DependencyObject)
VisualTreeExtensions.GetVisualDescendantsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualSiblings(DependencyObject)
VisualTreeExtensions.GetVisualSiblingsAndSelf(DependencyObject)
VisualTreeExtensions.GetBoundsRelativeTo(FrameworkElement, UIElement)
VisualTreeExtensions.InvokeOnLayoutUpdated(FrameworkElement, Action)
  • Improve this Doc
  • View Source