Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


BaseVerticalCollectionView

Base class for controls that display virtualized vertical content inside a scroll view.
Read time 10 minutesLast updated 5 days ago

Definition

public abstract class BaseVerticalCollectionView : BindableElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IBindable, ISerializationCallbackReceiver

Remarks

In BaseCollectionListView, the
id
represents a unique and stable identifier for each item. It is essential for operations like saving and restoring the state, such as expansions and selections. In contrast, the
index
indicates an item's position within the current view order, which can change based on user actions like sorting and filtering. You can use
id
to maintain distinct references, and use the
index
to handle rendering and layout tasks based on the visible order of items.

Static Fields

Value

Description

borderUssClassNameThe USS class name for BaseVerticalCollectionView elements with a border.
dragHoverBarUssClassNameThe USS class name of the drag hover bar.
dragHoverMarkerUssClassNameThe USS class name of the drag hover circular marker used to indicate depth.
itemAlternativeBackgroundUssClassNameThe USS class name for odd rows in the BaseVerticalCollectionView.
itemDragHoverUssClassNameThe USS class name applied to an item element on drag hover.
itemSelectedVariantUssClassNameThe USS class name of selected item elements in the BaseVerticalCollectionView.
itemUssClassNameThe USS class name of item elements in BaseVerticalCollectionView elements.
listScrollViewUssClassNameThe USS class name of the scroll view in the BaseVerticalCollectionView.
ussClassNameThe USS class name for BaseVerticalCollectionView elements.

Constructors

Constructor

Description

BaseVerticalCollectionView()Creates a BaseVerticalCollectionView with all default properties. The BaseVerticalCollectionView.itemsSource must all be set for the BaseVerticalCollectionView to function properly.
BaseVerticalCollectionView(System.Collections.IList,System.Single)Constructs a BaseVerticalCollectionView, with all required properties provided.

Properties

Property

Description

contentContainerReturns the content container for the BaseVerticalCollectionView. Because the BaseVerticalCollectionView control automatically manages its content, this always returns null.
fixedItemHeightThe height of a single item in the list, in pixels.
horizontalScrollingEnabledThis property controls whether the collection view shows a horizontal scroll bar when its content does not fit in the visible area.
itemsSourceThe data source for collection items.
reorderableGets or sets a value that indicates whether the user can drag list items to reorder them.
selectedIdsReturns the persistent IDs of selected items in the data source, regardless of whether they are collapsed or not. Always returns an enumerable, even if no item is selected, or a single item is selected.
selectedIndexReturns or sets the selected item's index in the data source. If multiple items are selected, returns the first selected item's index. If multiple items are provided, sets them all as selected. If no item is selected, returns -1.
selectedIndicesReturns the indices of selected items in the data source. Always returns an enumerable, even if no item is selected, or a single item is selected.
selectedItemReturns the selected item from the data source. If multiple items are selected, returns the first selected item.
selectedItemsReturns the selected items from the data source. Always returns an enumerable, even if no item is selected, or a single item is selected.
selectionTypeControls the selection type.
showAlternatingRowBackgroundsThis property controls whether the background colors of collection view rows alternate. Takes a value from the AlternatingRowBackground enum.
showBorderEnable this property to display a border around the collection view.
viewControllerThe view controller for this view.
virtualizationMethodThe virtualization method to use for this collection when a scroll bar is visible. Takes a value from the CollectionVirtualizationMethod enum.

Methods

Method

Description

AddToSelectionAdds an item to the collection of selected items.
ClearSelectionDeselects any selected items.
CreateViewControllerCreates the view controller for this view. Override this method in inheritors to change the controller type.
GetRootElementForIdGets the root element of the specified collection view item.
GetRootElementForIndexGets the root element of the specified collection view item.
RebuildClears the collection view, recreates all visible visual elements, and rebinds all items.
RefreshItemRebinds a single item if it is currently visible in the collection view.
RefreshItemsRebinds all items currently visible.
RemoveFromSelectionRemoves an item from the collection of selected items.
ScrollToScrolls to a specific VisualElement.
ScrollToItemScrolls to a specific item index and makes it visible.
ScrollToItemByIdScrolls to a specific item id and makes it visible.
SetSelectionSets a collection of selected items.
SetSelectionWithoutNotifySets a collection of selected items without triggering a selection change callback.
SetViewControllerAssigns the view controller for this view and registers all events required for it to function properly.

Events

Member

Description

canStartDragCalled when a drag operation wants to start in this collection view.
dragAndDropUpdateCalled when a drag operation updates in this collection view.
handleDropCalled when a drag operation is released in this collection view.
itemIndexChangedCalled when an item is moved in the itemsSource.
itemsChosenCallback triggered when the user acts on a selection of one or more items, for example by double-clicking or pressing Enter.
itemsSourceChangedRaised when the data source of a vertical collection view is assigned a new reference or new type.
selectedIndicesChangedCallback triggered when the selection changes.
selectionChangedCallback triggered when the selection changes.
setupDragAndDropCalled when a drag operation starts in this collection view.

Inheritance

Inherited Members