Skip to content

Latest commit

 

History

History
41 lines (23 loc) · 1.91 KB

virtualizinglayoutcontext_getorcreateelementat_1708765960.md

File metadata and controls

41 lines (23 loc) · 1.91 KB
-api-id -api-type
M:Microsoft.UI.Xaml.Controls.VirtualizingLayoutContext.GetOrCreateElementAt(System.Int32,Microsoft.UI.Xaml.Controls.ElementRealizationOptions)
winrt method

Microsoft.UI.Xaml.Controls.VirtualizingLayoutContext.GetOrCreateElementAt(System.Int32,Microsoft.UI.Xaml.Controls.ElementRealizationOptions)

-description

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

-parameters

-param index

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

-param options

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.

-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.

-see-also

-examples