Virtualize<TItem> Class

Definition

Provides functionality for rendering a virtualized list of items.

generic <typename TItem>
public ref class Virtualize sealed : Microsoft::AspNetCore::Components::ComponentBase, IAsyncDisposable
public sealed class Virtualize<TItem> : Microsoft.AspNetCore.Components.ComponentBase, IAsyncDisposable
type Virtualize<'Item> = class
    inherit ComponentBase
    interface IAsyncDisposable
Public NotInheritable Class Virtualize(Of TItem)
Inherits ComponentBase
Implements IAsyncDisposable

Type Parameters

TItem

The context type for the items being rendered.

Inheritance
Virtualize<TItem>
Implements

Constructors

Name Description
Virtualize<TItem>()

Properties

Name Description
AnchorMode

Gets or sets the anchor mode that controls how the viewport behaves at the edges of the list when new items arrive. The default is Beginning.

Assets

Gets the ResourceAssetCollection for the application.

(Inherited from ComponentBase)
AssignedRenderMode

Gets the IComponentRenderMode assigned to this component.

(Inherited from ComponentBase)
ChildContent

Gets or sets the item template for the list. See ItemContent.

EmptyContent

Gets or sets the content to show when Items is empty or when the TotalItemCount is zero.

ItemComparer

Gets or sets a comparer used to detect whether items were prepended or appended when using ItemsProvider. The comparer determines if the first loaded item changed between provider calls, which indicates items were inserted above.

Defaults to Default. For records and types implementing IEquatable<T>, the default works automatically (value equality). For classes without value-equality semantics, provide a comparer that compares by a unique identifier (e.g., Id); otherwise reference-equality fallback would produce false-positive prepend detection when the provider returns fresh instances.

Prepend detection only runs when this parameter is explicitly assigned by the consumer. The BL0011 analyzer warns when ItemsProvider is used without an explicit ItemComparer assignment.

For in-memory Items, this parameter is not needed because the component can detect prepends using object identity.

ItemContent

Gets or sets the item template for the list.

Items

Gets or sets the fixed item source.

ItemSize

Gets the size of each item in pixels. Defaults to 50px.

ItemsProvider

Gets or sets the function providing items to the list.

MaxItemCount

Gets or sets the maximum number of items that will be rendered, even if the client reports that its viewport is large enough to show more. The default value is 100.

This should only be used as a safeguard against excessive memory usage or large data loads. Do not set this to a smaller number than you expect to fit on a realistic-sized window, because that will leave a blank gap below and the user may not be able to see the rest of the content.

OverscanCount

Gets or sets a value that determines how many additional items will be rendered before and after the visible region. This help to reduce the frequency of rendering during scrolling. However, higher values mean that more elements will be present in the page.

Placeholder

Gets or sets the template for items that have not yet been loaded in memory.

RendererInfo

Gets the RendererInfo the component is running on.

(Inherited from ComponentBase)
SpacerElement

Gets or sets the tag name of the HTML element that will be used as the virtualization spacer. One such element will be rendered before the visible items, and one more after them, using an explicit "height" style to control the scroll range.

The default value is "div". If you are placing the Virtualize<TItem> instance inside an element that requires a specific child tag name, consider setting that here. For example when rendering inside a "tbody", consider setting SpacerElement to the value "tr".

Methods

Name Description
BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

(Inherited from ComponentBase)
DispatchExceptionAsync(Exception)

Treats the supplied exception as being thrown by this component. This will cause the enclosing ErrorBoundary to transition into a failed state. If there is no enclosing ErrorBoundary, it will be regarded as an exception from the enclosing renderer.

This is useful if an exception occurs outside the component lifecycle methods, but you wish to treat it the same as an exception from a component lifecycle method.

(Inherited from ComponentBase)
DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

InvokeAsync(Action)

Executes the supplied work item on the associated renderer's synchronization context.

(Inherited from ComponentBase)
InvokeAsync(Func<Task>)

Executes the supplied work item on the associated renderer's synchronization context.

(Inherited from ComponentBase)
OnAfterRender(Boolean)

Method invoked after each time the component has rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any ElementReference fields will be populated by the time this runs.

This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.

(Inherited from ComponentBase)
OnAfterRenderAsync(Boolean)

Method invoked after each time the component has been rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any ElementReference fields will be populated by the time this runs.

This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.

Note that the component does not automatically re-render after the completion of any returned Task, because that would cause an infinite render loop.

(Inherited from ComponentBase)
OnInitialized()

Method invoked when the component is ready to start, having received its initial parameters from its parent in the render tree.

(Inherited from ComponentBase)
OnInitializedAsync()

Method invoked when the component is ready to start, having received its initial parameters from its parent in the render tree.

Override this method if you will perform an asynchronous operation and want the component to refresh when that operation is completed.

(Inherited from ComponentBase)
OnParametersSet()

Method invoked when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties.

(Inherited from ComponentBase)
OnParametersSetAsync()

Method invoked when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties.

(Inherited from ComponentBase)
RefreshDataAsync()

Instructs the component to re-request data from its ItemsProvider. This is useful if external data may have changed. There is no need to call this when using Items.

SetParametersAsync(ParameterView)

Sets parameters supplied by the component's parent in the render tree.

(Inherited from ComponentBase)
ShouldRender()

Returns a flag to indicate whether the component should render.

(Inherited from ComponentBase)
StateHasChanged()

Notifies the component that its state has changed. When applicable, this will cause the component to be re-rendered.

(Inherited from ComponentBase)

Explicit Interface Implementations

Name Description
IComponent.Attach(RenderHandle) (Inherited from ComponentBase)
IHandleAfterRender.OnAfterRenderAsync() (Inherited from ComponentBase)
IHandleEvent.HandleEventAsync(EventCallbackWorkItem, Object) (Inherited from ComponentBase)

Applies to