docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GridView

    A view containing recycled rows with items inside.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    BindableElement
    BaseGridView
    GridView
    Implements
    IEventHandler
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IResolvedStyle
    IBindable
    ISerializationCallbackReceiver
    Inherited Members
    BaseGridView.ussClassName
    BaseGridView.itemUssClassName
    BaseGridView.firstColumnUssClassName
    BaseGridView.lastColumnUssClassName
    BaseGridView.scrollView
    BaseGridView.CancelDrag()
    BaseGridView.bindItem
    BaseGridView.columnCount
    BaseGridView.dragger
    BaseGridView.operationMask
    BaseGridView.contentContainer
    BaseGridView.itemWidth
    BaseGridView.itemsSource
    BaseGridView.makeItem
    BaseGridView.resolvedItemWidth
    BaseGridView.selectedIndex
    BaseGridView.selectedIndices
    BaseGridView.selectedItem
    BaseGridView.selectedItems
    BaseGridView.selectedIds
    BaseGridView.selectionCount
    BaseGridView.IsSelectedId(int)
    BaseGridView.selectionType
    BaseGridView.allowNoSelection
    BaseGridView.isSelecting
    BaseGridView.preventScrollWithModifiers
    BaseGridView.unbindItem
    BaseGridView.getItemId
    BaseGridView.itemsChosen
    BaseGridView.selectionChanged
    BaseGridView.selectedIndicesChanged
    BaseGridView.contextClicked
    BaseGridView.doubleClicked
    BaseGridView.dragStarted
    BaseGridView.dragUpdated
    BaseGridView.dragFinished
    BaseGridView.dragCanceled
    BaseGridView.AddToSelection(int)
    BaseGridView.ClearSelection()
    BaseGridView.ClearSelectionWithoutNotify()
    BaseGridView.RemoveFromSelection(int)
    BaseGridView.SetSelection(int)
    BaseGridView.SetSelection(IEnumerable<int>)
    BaseGridView.SetSelectionWithoutNotify(IEnumerable<int>)
    BaseGridView.GetIdFromIndex(int)
    BaseGridView.HasValidDataAndBindings()
    BaseGridView.PostSelection(bool, bool)
    BindableElement.binding
    BindableElement.bindingPath
    VisualElement.disabledUssClassName
    VisualElement.ExecuteDefaultAction(EventBase)
    VisualElement.Focus()
    VisualElement.SendEvent(EventBase)
    VisualElement.SetEnabledFromHierarchy(bool)
    VisualElement.SetEnabled(bool)
    VisualElement.MarkDirtyRepaint()
    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.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.usageHints
    VisualElement.transform
    VisualElement.layout
    VisualElement.contentRect
    VisualElement.paddingRect
    VisualElement.worldBound
    VisualElement.localBound
    VisualElement.worldTransform
    VisualElement.pickingMode
    VisualElement.name
    VisualElement.enabledInHierarchy
    VisualElement.enabledSelf
    VisualElement.visible
    VisualElement.generateVisualContent
    VisualElement.experimental
    VisualElement.hierarchy
    VisualElement.cacheAsBitmap
    VisualElement.parent
    VisualElement.panel
    VisualElement.visualTreeAssetSource
    VisualElement.this[int]
    VisualElement.childCount
    VisualElement.schedule
    VisualElement.style
    VisualElement.customStyle
    VisualElement.styleSheets
    VisualElement.tooltip
    VisualElement.resolvedStyle
    Focusable.Blur()
    Focusable.focusable
    Focusable.tabIndex
    Focusable.delegatesFocus
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TrickleDown)
    CallbackEventHandler.HandleEvent(EventBase)
    CallbackEventHandler.HasTrickleDownHandlers()
    CallbackEventHandler.HasBubbleUpHandlers()
    CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
    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
    public class GridView : BaseGridView, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable, ISerializationCallbackReceiver

    Constructors

    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.

    Declaration
    public GridView()

    GridView(IList, Func<VisualElement>, Action<VisualElement, int>)

    Constructs a GridView, with all required properties provided.

    Declaration
    public GridView(IList itemsSource, Func<VisualElement> makeItem, Action<VisualElement, int> bindItem)
    Parameters
    Type Name Description
    IList itemsSource

    The list of items to use as a data source.

    Func<VisualElement> makeItem

    The factory method to call to create a display item. The method should return a VisualElement that can be bound to a data item.

    Action<VisualElement, int> bindItem

    The method to call to bind a data item to a display item. The method receives as parameters the display item to bind, and the index of the data item to bind it to.

    Properties

    itemHeight

    The height of a single item in the list, in pixels.

    Declaration
    public int itemHeight { get; set; }
    Property Value
    Type Description
    int
    Remarks

    GridView requires that all visual elements have the same height so that it can calculate the scroller size.

    This property must be set for the list view to function.

    resolvedItemHeight

    The computed pixel-aligned height for the list elements.

    Declaration
    public float resolvedItemHeight { get; }
    Property Value
    Type Description
    float
    Remarks

    This value changes depending on the current panel's DPI scaling.

    See Also
    itemHeight

    Methods

    ApplySelectedState()

    Set the selected visual state on items.

    Declaration
    protected override void ApplySelectedState()
    Overrides
    BaseGridView.ApplySelectedState()

    GetIndexByWorldPosition(Vector2)

    Returns the index of the item at the given position.

    Declaration
    public override int GetIndexByWorldPosition(Vector2 worldPosition)
    Parameters
    Type Name Description
    Vector2 worldPosition

    The position of the item in the world-space.

    Returns
    Type Description
    int

    The index of the item at the given position.

    Overrides
    BaseGridView.GetIndexByWorldPosition(Vector2)
    Remarks

    The position is relative to the top left corner of the grid. No check is made to see if the index is valid.

    GetVisualElementInternal(int)

    Implement this method to return the VisualElement at the specified index.

    Declaration
    protected override VisualElement GetVisualElementInternal(int index)
    Parameters
    Type Name Description
    int index

    The index of the VisualElement to return.

    Returns
    Type Description
    VisualElement

    The VisualElement at the specified index.

    Overrides
    BaseGridView.GetVisualElementInternal(int)

    OnContainerHeightChanged(float)

    Callback called when the ScrollView container height changes.

    Declaration
    protected override void OnContainerHeightChanged(float height)
    Parameters
    Type Name Description
    float height

    The new height of the container.

    Overrides
    BaseGridView.OnContainerHeightChanged(float)

    OnCustomStyleResolved(CustomStyleResolvedEvent)

    Method to implement to handle the custom style resolved event.

    Declaration
    protected override void OnCustomStyleResolved(CustomStyleResolvedEvent e)
    Parameters
    Type Name Description
    CustomStyleResolvedEvent e

    The custom style resolved event.

    Overrides
    BaseGridView.OnCustomStyleResolved(CustomStyleResolvedEvent)

    OnScroll(float)

    Callback called when the scroll value changes.

    Declaration
    protected override void OnScroll(float offset)
    Parameters
    Type Name Description
    float offset

    The new scroll offset.

    Overrides
    BaseGridView.OnScroll(float)
    Remarks

    You can also call this method one frame your Refresh() implementation to ensure the visual state of the grid is updated correctly.

    Refresh()

    Clears the GridView, recreates all visible visual elements, and rebinds all items.

    Declaration
    public override void Refresh()
    Overrides
    BaseGridView.Refresh()
    Remarks

    Call this method whenever the data source changes.

    ScrollToItem(int)

    Scrolls to a specific item index and makes it visible.

    Declaration
    public override void ScrollToItem(int index)
    Parameters
    Type Name Description
    int index

    Item index to scroll to. Specify -1 to make the last item visible.

    Overrides
    BaseGridView.ScrollToItem(int)

    Implements

    IEventHandler
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IResolvedStyle
    IBindable
    ISerializationCallbackReceiver

    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.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 © 2025 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)