VirtualizingLayoutContext.

GetOrCreateElementAt(int, ElementRealizationOptions) Method

Summary

Retrieves a UIElement that represents the data item in the source found at the specified index using the specified options.
Namespace
Avalonia.Layout
Containing Type
VirtualizingLayoutContext

Syntax

public ILayoutable GetOrCreateElementAt(int index, ElementRealizationOptions options)

Remarks

This method calls GetOrCreateElementAtCore(int, ElementRealizationOptions), which must be implemented in a derived class. When you request an element for the specified index, you can optionally specify whether to suppress automatic recycling of the retrieved element or force creation of a new element.Elements retrieved with automatic recycling suppressed(SuppressAutoRecycle) are ignored by the automatic recycling logic that clears realized elements that were not retrieved as part of the current layout pass.You must explicitly recycle these elements by passing them to the RecycleElement method to avoid memory leaks. These options are intended for more advanced layouts that choose to explicitly manage the realization and recycling of elements as a performance optimization.

Parameters

Name Type Description
index int The index of the data item to retrieve a UIElement for.
options ElementRealizationOptions A value of ElementRealizationOptions that specifies whether to suppress automatic recycling of the retrieved element or force creation of a new element.

Return Value

Type Description
ILayoutable