BaseVerticalCollectionView
Base class for controls that display virtualized vertical content inside a scroll view.
Read time 10 minutesLast updated 5 days ago
Definition
- Type: Class
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
- Inherits from: BindableElement
- Implements: IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IBindable, ISerializationCallbackReceiver
public abstract class BaseVerticalCollectionView : BindableElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IBindable, ISerializationCallbackReceiver
Remarks
In BaseCollectionListView, the 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 indicates an item's position within the current view order, which can change based on user actions like sorting and filtering. You can use to maintain distinct references, and use the to handle rendering and layout tasks based on the visible order of items.
idindexidindexStatic Fields
Value | Description |
|---|---|
| borderUssClassName | The USS class name for BaseVerticalCollectionView elements with a border. |
| dragHoverBarUssClassName | The USS class name of the drag hover bar. |
| dragHoverMarkerUssClassName | The USS class name of the drag hover circular marker used to indicate depth. |
| itemAlternativeBackgroundUssClassName | The USS class name for odd rows in the BaseVerticalCollectionView. |
| itemDragHoverUssClassName | The USS class name applied to an item element on drag hover. |
| itemSelectedVariantUssClassName | The USS class name of selected item elements in the BaseVerticalCollectionView. |
| itemUssClassName | The USS class name of item elements in BaseVerticalCollectionView elements. |
| listScrollViewUssClassName | The USS class name of the scroll view in the BaseVerticalCollectionView. |
| ussClassName | The 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 |
|---|---|
| contentContainer | Returns the content container for the BaseVerticalCollectionView. Because the BaseVerticalCollectionView control automatically manages its content, this always returns null. |
| fixedItemHeight | The height of a single item in the list, in pixels. |
| horizontalScrollingEnabled | This property controls whether the collection view shows a horizontal scroll bar when its content does not fit in the visible area. |
| itemsSource | The data source for collection items. |
| reorderable | Gets or sets a value that indicates whether the user can drag list items to reorder them. |
| selectedIds | Returns 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. |
| selectedIndex | Returns 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. |
| selectedIndices | Returns 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. |
| selectedItem | Returns the selected item from the data source. If multiple items are selected, returns the first selected item. |
| selectedItems | Returns the selected items from the data source. Always returns an enumerable, even if no item is selected, or a single item is selected. |
| selectionType | Controls the selection type. |
| showAlternatingRowBackgrounds | This property controls whether the background colors of collection view rows alternate. Takes a value from the AlternatingRowBackground enum. |
| showBorder | Enable this property to display a border around the collection view. |
| viewController | The view controller for this view. |
| virtualizationMethod | The virtualization method to use for this collection when a scroll bar is visible. Takes a value from the CollectionVirtualizationMethod enum. |
Methods
Method | Description |
|---|---|
| AddToSelection | Adds an item to the collection of selected items. |
| ClearSelection | Deselects any selected items. |
| CreateViewController | Creates the view controller for this view. Override this method in inheritors to change the controller type. |
| GetRootElementForId | Gets the root element of the specified collection view item. |
| GetRootElementForIndex | Gets the root element of the specified collection view item. |
| Rebuild | Clears the collection view, recreates all visible visual elements, and rebinds all items. |
| RefreshItem | Rebinds a single item if it is currently visible in the collection view. |
| RefreshItems | Rebinds all items currently visible. |
| RemoveFromSelection | Removes an item from the collection of selected items. |
| ScrollTo | Scrolls to a specific VisualElement. |
| ScrollToItem | Scrolls to a specific item index and makes it visible. |
| ScrollToItemById | Scrolls to a specific item id and makes it visible. |
| SetSelection | Sets a collection of selected items. |
| SetSelectionWithoutNotify | Sets a collection of selected items without triggering a selection change callback. |
| SetViewController | Assigns the view controller for this view and registers all events required for it to function properly. |
Events
Member | Description |
|---|---|
| canStartDrag | Called when a drag operation wants to start in this collection view. |
| dragAndDropUpdate | Called when a drag operation updates in this collection view. |
| handleDrop | Called when a drag operation is released in this collection view. |
| itemIndexChanged | Called when an item is moved in the itemsSource. |
| itemsChosen | Callback triggered when the user acts on a selection of one or more items, for example by double-clicking or pressing Enter. |
| itemsSourceChanged | Raised when the data source of a vertical collection view is assigned a new reference or new type. |
| selectedIndicesChanged | Callback triggered when the selection changes. |
| selectionChanged | Callback triggered when the selection changes. |
| setupDragAndDrop | Called when a drag operation starts in this collection view. |