Share via


VirtualizingLayoutContext.GetOrCreateElementAtCore Method

Definition

When implemented in a derived class, retrieves a UIElement that represents the data item in the source found at the specified index using the specified options.

This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

protected:
 virtual UIElement ^ GetOrCreateElementAtCore(int index, ElementRealizationOptions options) = GetOrCreateElementAtCore;
UIElement GetOrCreateElementAtCore(int const& index, ElementRealizationOptions const& options);
protected virtual UIElement GetOrCreateElementAtCore(int index, ElementRealizationOptions options);
Protected Overridable Function GetOrCreateElementAtCore (index As Integer, options As ElementRealizationOptions) As UIElement

Parameters

index
Int32

int

The index of the data item to retrieve a UIElement for.

options
ElementRealizationOptions

Specifies whether to suppress automatic recycling of the retrieved element or force creation of a new element.

Returns

A UIElement that represents the data item.

Remarks

This method is called by GetOrCreateElementAt(System.Int32) and GetOrCreateElementAt(System.Int32,Microsoft.UI.Xaml.Controls.ElementRealizationOptions).

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 RecycleElementCore(Windows.UI.Xaml.UIElement) 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.

Applies to