docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TreeListVirtual

    A tree whose rows are windowed: only the rows near the scrolled view exist as TreeViewItem elements, so a tree of any size costs a constant number of elements. A port of the web registry's TreeListVirtual.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    BaseVisualElement
    TreeListVirtual
    Implements
    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder
    ISizeableElement
    Inherited Members
    BaseVisualElement.contextPrefix
    BaseVisualElement.densityOverride
    BaseVisualElement.themeOverride
    BaseVisualElement.langOverride
    BaseVisualElement.layoutDirectionOverride
    BaseVisualElement.preferredTooltipPlacementOverride
    BaseVisualElement.tooltipDelayMsOverride
    BaseVisualElement.GetLayoutDirectionUssClassName(Dir)
    VisualElement.disabledUssClassName
    VisualElement.SetActivePseudoState(bool)
    VisualElement.SetCheckedPseudoState(bool)
    VisualElement.Focus()
    VisualElement.SendEvent(EventBase)
    VisualElement.SetEnabledFromHierarchy(bool)
    VisualElement.SetEnabled(bool)
    VisualElement.MarkDirtyRepaint()
    VisualElement.IsMarkedForRepaint()
    VisualElement.ContainsPoint(Vector2)
    VisualElement.Overlaps(Rect)
    VisualElement.DoMeasure(float, VisualElement.MeasureMode, float, VisualElement.MeasureMode)
    VisualElement.ToString()
    VisualElement.GetClasses()
    VisualElement.ClearClassList()
    VisualElement.AddToClassList(string)
    VisualElement.RemoveFromClassList(string)
    VisualElement.ToggleInClassList(string)
    VisualElement.EnableInClassList(string, bool)
    VisualElement.ClassListContains(string)
    VisualElement.FindAncestorUserData()
    VisualElement.SetBinding(BindingId, Binding)
    VisualElement.GetBinding(BindingId)
    VisualElement.TryGetBinding(BindingId, out Binding)
    VisualElement.GetBindingInfos()
    VisualElement.GetBindingInfos(List<BindingInfo>)
    VisualElement.HasBinding(BindingId)
    VisualElement.ClearBinding(BindingId)
    VisualElement.ClearBindings()
    VisualElement.GetHierarchicalDataSourceContext()
    VisualElement.GetDataSourceContext(BindingId)
    VisualElement.TryGetDataSourceContext(BindingId, out DataSourceContext)
    VisualElement.TryGetLastBindingToUIResult(in BindingId, out BindingResult)
    VisualElement.TryGetLastBindingToSourceResult(in BindingId, out BindingResult)
    VisualElement.Add(VisualElement)
    VisualElement.Insert(int, VisualElement)
    VisualElement.Remove(VisualElement)
    VisualElement.RemoveAt(int)
    VisualElement.Clear()
    VisualElement.ElementAt(int)
    VisualElement.IndexOf(VisualElement)
    VisualElement.Children()
    VisualElement.Sort(Comparison<VisualElement>)
    VisualElement.BringToFront()
    VisualElement.SendToBack()
    VisualElement.PlaceBehind(VisualElement)
    VisualElement.PlaceInFront(VisualElement)
    VisualElement.RemoveFromHierarchy()
    VisualElement.GetFirstOfType<T>()
    VisualElement.GetFirstAncestorOfType<T>()
    VisualElement.Contains(VisualElement)
    VisualElement.FindCommonAncestor(VisualElement)
    VisualElement.viewDataKey
    VisualElement.userData
    VisualElement.canGrabFocus
    VisualElement.focusController
    VisualElement.disablePlayModeTint
    VisualElement.usageHints
    VisualElement.transform
    VisualElement.scaledPixelsPerPoint
    VisualElement.layout
    VisualElement.contentRect
    VisualElement.paddingRect
    VisualElement.worldBound
    VisualElement.localBound
    VisualElement.worldTransform
    VisualElement.hasActivePseudoState
    VisualElement.hasInactivePseudoState
    VisualElement.hasHoverPseudoState
    VisualElement.hasCheckedPseudoState
    VisualElement.hasEnabledPseudoState
    VisualElement.hasDisabledPseudoState
    VisualElement.hasFocusPseudoState
    VisualElement.hasRootPseudoState
    VisualElement.pickingMode
    VisualElement.name
    VisualElement.enabledInHierarchy
    VisualElement.enabledSelf
    VisualElement.languageDirection
    VisualElement.visible
    VisualElement.generateVisualContent
    VisualElement.dataSource
    VisualElement.dataSourcePath
    VisualElement.dataSourceType
    VisualElement.experimental
    VisualElement.hierarchy
    VisualElement.cacheAsBitmap
    VisualElement.parent
    VisualElement.panel
    VisualElement.contentContainer
    VisualElement.visualTreeAssetSource
    VisualElement.this[int]
    VisualElement.childCount
    VisualElement.schedule
    VisualElement.style
    VisualElement.resolvedStyle
    VisualElement.customStyle
    VisualElement.styleSheets
    VisualElement.tooltip
    Focusable.Blur()
    Focusable.focusable
    Focusable.tabIndex
    Focusable.delegatesFocus
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, CallbackOptions)
    CallbackEventHandler.UnregisterAllRemovableCallbacks()
    CallbackEventHandler.HasTrickleDownHandlers()
    CallbackEventHandler.HasBubbleUpHandlers()
    CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
    CallbackEventHandler.HandleEventBubbleUp(EventBase)
    CallbackEventHandler.HandleEventTrickleDown(EventBase)
    CallbackEventHandler.ExecuteDefaultAction(EventBase)
    CallbackEventHandler.NotifyPropertyChanged(in BindingId)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.AppUI.UI
    Assembly: Unity.AppUI.dll
    Syntax
    [UxmlElement]
    public class TreeListVirtual : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, ISizeableElement
    Remarks

    TreeList stays a composition container: its consumer builds every TreeViewItem, and its public surface (items, selectedItems, onReparent) hands out those element references, so it cannot recycle rows without breaking that contract. This sibling takes the rows as data instead, flat and in display order (see Flatten<T>(TreeListFlattenOptions<T>)), and recycles a small pool of items over them. Selection is therefore by row id rather than by element.

    Selection (with the same press-then-release rule as TreeList in Multiple mode) and keyboard navigation (arrows, Home / End, Shift-range, action+A, Escape, Delete) read the row list rather than the realised elements, so they reach rows that are not realised. Expansion is the caller's: a caret click or an arrow key reports it through onExpandedChange and the caller rebuilds rows. Rows are a uniform height, the height of the first realised row. Drag to reorder is not supported yet.

    Constructors

    TreeListVirtual()

    Initializes a new instance of the TreeListVirtual class.

    Declaration
    public TreeListVirtual()

    Fields

    indentProbeUssClassName

    The USS class name of the hidden element whose width is the per-level indent.

    Declaration
    public const string indentProbeUssClassName = "appui-tree-list-virtual__indent-probe"
    Field Value
    Type Description
    string

    placeholderUssClassName

    The USS class name of a realised placeholder row.

    Declaration
    public const string placeholderUssClassName = "appui-tree-list-virtual__row--placeholder"
    Field Value
    Type Description
    string

    rowUssClassName

    The USS class name of a realised row.

    Declaration
    public const string rowUssClassName = "appui-tree-list-virtual__row"
    Field Value
    Type Description
    string

    rowsContainerUssClassName

    The USS class name of the element sized to the whole row list.

    Declaration
    public const string rowsContainerUssClassName = "appui-tree-list-virtual__rows"
    Field Value
    Type Description
    string

    scrollViewUssClassName

    The USS class name of the scroll view.

    Declaration
    public const string scrollViewUssClassName = "appui-tree-list-virtual__scroll-view"
    Field Value
    Type Description
    string

    ussClassName

    The TreeListVirtual's main USS class name. The element also carries ussClassName, so the rows pick up the tree's row styling.

    Declaration
    public const string ussClassName = "appui-tree-list-virtual"
    Field Value
    Type Description
    string

    Properties

    bindRow

    Draws one row onto a recycled TreeViewItem: its label, icon and anything else that comes from the caller's item. The tree has already set the row's indentation, caret, expansion and selection. Called for placeholders too; check placeholder. With no handler, the row shows its id.

    Declaration
    public Action<TreeViewItem, TreeListRow, int> bindRow { get; set; }
    Property Value
    Type Description
    Action<TreeViewItem, TreeListRow, int>

    onDeleteSelection

    Called when Delete or Backspace is pressed with a non-empty selection, receiving the selected ids in priority order. There is no default behaviour.

    Declaration
    public Action<IReadOnlyList<string>> onDeleteSelection { get; set; }
    Property Value
    Type Description
    Action<IReadOnlyList<string>>

    onExpandedChange

    Called with a row's id and its requested state when a caret click or an arrow key expands or collapses it. The caller updates its expansion state and assigns new rows.

    Declaration
    public Action<string, bool> onExpandedChange { get; set; }
    Property Value
    Type Description
    Action<string, bool>

    overscan

    Rows realised beyond each edge of the view. -1, the default, realises one view's worth, and never fewer than 10, so a scroll of up to a full view in one frame still lands on realised rows.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public int overscan { get; set; }
    Property Value
    Type Description
    int

    pinnedIds

    Row ids kept realised even when scrolled out of view, a row being renamed for instance. The lead selected row and a row being pressed are always kept.

    Declaration
    public IReadOnlyList<string> pinnedIds { get; set; }
    Property Value
    Type Description
    IReadOnlyList<string>

    realisedRowCount

    How many rows currently exist as elements.

    Declaration
    public int realisedRowCount { get; }
    Property Value
    Type Description
    int

    rowSize

    The height every row is laid out at, measured from the first realised row.

    Declaration
    public float rowSize { get; }
    Property Value
    Type Description
    float

    rows

    Every visible row in display order, placeholders included. Assigning it rebinds the realised rows. The selection is kept by id.

    Declaration
    public IReadOnlyList<TreeListRow> rows { get; set; }
    Property Value
    Type Description
    IReadOnlyList<TreeListRow>

    scrollView

    The scroll view the rows are windowed against.

    Declaration
    public ScrollView scrollView { get; }
    Property Value
    Type Description
    ScrollView

    selectedId

    The lead selected row id, or null.

    Declaration
    public string selectedId { get; }
    Property Value
    Type Description
    string

    selectedIds

    The selected row ids in priority order. Index 0 is the lead, the row the user acted on last, which keyboard navigation moves from.

    Declaration
    public IReadOnlyList<string> selectedIds { get; }
    Property Value
    Type Description
    IReadOnlyList<string>

    selectionType

    How many rows the user can select at once. Defaults to Single. Narrowing it trims the current selection.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public SelectionType selectionType { get; set; }
    Property Value
    Type Description
    SelectionType

    size

    The size of the rows. Cascades onto the rows the same way size does.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public Size size { get; set; }
    Property Value
    Type Description
    Size

    Methods

    ClearSelection()

    Clears the selection.

    Declaration
    public void ClearSelection()

    GetRealisedItem(int)

    The realised item drawing the row at index, or null when that row is not realised.

    Declaration
    public TreeViewItem GetRealisedItem(int index)
    Parameters
    Type Name Description
    int index

    The row index.

    Returns
    Type Description
    TreeViewItem

    The item, or null.

    IndexOf(string)

    The index of the item row with this id, or -1. Placeholders are not indexed.

    Declaration
    public int IndexOf(string id)
    Parameters
    Type Name Description
    string id

    The row id.

    Returns
    Type Description
    int

    The index, or -1.

    IsIndexVisible(int)

    Whether the row at index lies entirely inside the scrolled view.

    Declaration
    public bool IsIndexVisible(int index)
    Parameters
    Type Name Description
    int index

    The row index.

    Returns
    Type Description
    bool

    True when the whole row is visible.

    ScrollToIndex(int)

    Scrolls the least distance that brings the row at index fully into view.

    Declaration
    public void ScrollToIndex(int index)
    Parameters
    Type Name Description
    int index

    The row index.

    Select(string, bool, bool)

    Applies a user selection gesture to the row with this id, the same way a click does.

    Declaration
    public void Select(string id, bool shift = false, bool toggle = false)
    Parameters
    Type Name Description
    string id

    The row id.

    bool shift

    True when the range modifier is held (Multiple mode only).

    bool toggle

    True when the action key is held (Multiple mode only).

    SelectAll()

    Selects every item row. Only valid in Multiple mode.

    Declaration
    public void SelectAll()

    SetSelection(IEnumerable<string>)

    Replaces the selection with these ids, the first being the lead, and raises selectionChanged when it changes.

    Declaration
    public void SetSelection(IEnumerable<string> ids)
    Parameters
    Type Name Description
    IEnumerable<string> ids

    The ids to select.

    Events

    selectionChanged

    Raised when the selection changes, with the selected ids in priority order.

    Declaration
    public event Action<IReadOnlyList<string>> selectionChanged
    Event Type
    Type Description
    Action<IReadOnlyList<string>>

    Implements

    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder
    ISizeableElement

    Extension Methods

    VisualElementExtensions.FindNavController(VisualElement)
    RegisterUpdateCallbackExtensions.RegisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    RegisterUpdateCallbackExtensions.UnregisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    VisualElementExtensions.EnableDynamicTransform(VisualElement, bool)
    VisualElementExtensions.EnablePicking(VisualElement, bool)
    VisualElementExtensions.GetChildren<T>(VisualElement, bool)
    VisualElementExtensions.GetContextProvider<T>(VisualElement)
    VisualElementExtensions.GetContextProvider<T>(VisualElement, string)
    VisualElementExtensions.GetContext<T>(VisualElement)
    VisualElementExtensions.GetContext<T>(VisualElement, string)
    VisualElementExtensions.GetExclusiveRootElement(VisualElement)
    VisualElementExtensions.GetLastAncestorOfType<T>(VisualElement)
    VisualElementExtensions.GetPreferredTooltipPlacement(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement, string)
    VisualElementExtensions.GetTooltipContent(VisualElement)
    VisualElementExtensions.GetTooltipTemplate(VisualElement)
    VisualElementExtensions.HasAncestorOfType<T>(VisualElement, bool)
    VisualElementExtensions.HasAncestorsOfType<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement, string)
    VisualElementExtensions.IsInvisible(VisualElement)
    VisualElementExtensions.IsOnScreen(VisualElement)
    VisualElementExtensions.ProvideContext<T>(VisualElement, string, T)
    VisualElementExtensions.ProvideContext<T>(VisualElement, T)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.SetPreferredTooltipPlacement(VisualElement, OptionalEnum<PopoverPlacement>)
    VisualElementExtensions.SetTooltipContent(VisualElement, VisualElementExtensions.TooltipContentCallback)
    VisualElementExtensions.SetTooltipTemplate(VisualElement, VisualElement)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)