Class GridView
A view containing recycled rows with items inside.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: solution.dll
Syntax
public class GridView : BindableElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable, ISerializationCallbackReceiver
Constructors
Name | Description |
---|---|
GridView() | Creates a GridView with all default properties. The itemsSource, itemHeight, makeItem and bindItem properties must all be set for the GridView to function properly. |
GridView(IList, Func<VisualElement>, Action<VisualElement, int>) | Constructs a GridView, with all required properties provided. |
Fields
Name | Description |
---|---|
ussClassName | The USS class name for GridView elements. |
Properties
Name | Description |
---|---|
allowNoSelection | Whether the GridView allows to have no selection when the selection type is Single or Multiple. |
bindItem | Callback for binding a data item to the visual element. |
columnCount | The number of columns for this grid. |
contentContainer | Returns the content container for the GridView. Because the GridView control automatically manages its content, this always returns null. |
dragger | |
isSelecting | Returns true if the soft-selection is in progress. |
itemHeight | The height of a single item in the list, in pixels. |
itemWidth | |
itemsSource | The data source for list items. |
makeItem | Callback for constructing the VisualElement that is the template for each recycled and re-bound element in the list. |
operationMask | A mask describing available operations in this GridView when the user interacts with it. |
preventScrollWithModifiers | Prevents the grid view from scrolling when the user presses a modifier key at the same time as scrolling. |
resolvedItemHeight | The computed pixel-aligned height for the list elements. |
resolvedItemWidth | |
scrollView | The ScrollView used by the GridView. |
selectedIds | Returns the IDs of selected items in the data source. 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. |
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. |
showBorder | Enable this property to display a border around the GridView. |
unbindItem | Callback for unbinding a data item from the VisualElement. |
Methods
Name | Description |
---|---|
AddToSelection(int) | Adds an item to the collection of selected items. |
CancelDrag() | Cancel drag operation. |
ClearSelection() | Deselects any selected items. |
ClearSelectionWithoutNotify() | |
GetIndexByWorldPosition(Vector2) | Returns the index of the item at the given position. |
Refresh() | Clears the GridView, recreates all visible visual elements, and rebinds all items. |
RemoveFromSelection(int) | Removes an item from the collection of selected items. |
ScrollToItem(int) | Scrolls to a specific item index and makes it visible. |
SetSelection(IEnumerable<int>) | Sets a collection of selected items. |
SetSelection(int) | Sets the currently selected item. |
SetSelectionWithoutNotify(IEnumerable<int>) | Sets a collection of selected items without triggering a selection change callback. |
Events
Name | Description |
---|---|
contextClicked | Callback triggered when the user right-clicks on an item. |
doubleClicked | Callback triggered when the user double-clicks on an item. |
dragCanceled | Callback triggered when drag has been canceled. |
dragFinished | Callback triggered when drag has finished. |
dragStarted | Callback triggered when drag has started. |
dragUpdated | Callback triggered when items are dragged. |
itemsChosen | Callback triggered when the user acts on a selection of one or more items, for example by double-clicking or pressing Enter. |
selectedIndicesChanged | Callback triggered when the selection changes. |
selectionChanged | Callback triggered when the selection changes. |