Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

VirtualizingLayoutContext.GetOrCreateElementAt Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
GetOrCreateElementAt(Int32)

Retrieves a UIElement that represents the data item in the source found at the specified index. By default, if an element already exists, it is returned; otherwise, a new element is created.

GetOrCreateElementAt(Int32, ElementRealizationOptions)

Retrieves a UIElement that represents the data item in the source found at the specified index using the specified options.

GetOrCreateElementAt(Int32)

Retrieves a UIElement that represents the data item in the source found at the specified index. By default, if an element already exists, it is returned; otherwise, a new element is created.

public:
 virtual UIElement ^ GetOrCreateElementAt(int index) = GetOrCreateElementAt;
/// [Windows.Foundation.Metadata.Overload("GetOrCreateElementAt")]
UIElement GetOrCreateElementAt(int const& index);
[Windows.Foundation.Metadata.Overload("GetOrCreateElementAt")]
public UIElement GetOrCreateElementAt(int index);
function getOrCreateElementAt(index)
Public Function GetOrCreateElementAt (index As Integer) As UIElement

Parameters

index
Int32

int

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

Returns

A UIElement that represents the data item.

Attributes

Remarks

This method calls GetOrCreateElementAtCore(System.Int32,Microsoft.UI.Xaml.Controls.ElementRealizationOptions) with options set to None.

GetElementAtCore must be implemented in a derived class.

Applies to

GetOrCreateElementAt(Int32, ElementRealizationOptions)

Retrieves a UIElement that represents the data item in the source found at the specified index using the specified options.

public:
 virtual UIElement ^ GetOrCreateElementAt(int index, ElementRealizationOptions options) = GetOrCreateElementAt;
/// [Windows.Foundation.Metadata.Overload("GetOrCreateElementAt2")]
UIElement GetOrCreateElementAt(int const& index, ElementRealizationOptions const& options);
[Windows.Foundation.Metadata.Overload("GetOrCreateElementAt2")]
public UIElement GetOrCreateElementAt(int index, ElementRealizationOptions options);
function getOrCreateElementAt(index, options)
Public Function GetOrCreateElementAt (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

A value of ElementRealizationOptions that 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.

Attributes

Remarks

This method calls GetOrCreateElementAtCore(System.Int32,Microsoft.UI.Xaml.Controls.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.

Applies to


Feedback

Was this page helpful?