Share via


ItemsRepeater.GetOrCreateElement(Int32) Method

Definition

Retrieves the UIElement that corresponds to the item at the specified index in the data source.

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

public:
 virtual UIElement ^ GetOrCreateElement(int index) = GetOrCreateElement;
UIElement GetOrCreateElement(int const& index);
public UIElement GetOrCreateElement(int index);
Public Function GetOrCreateElement (index As Integer) As UIElement

Parameters

index
Int32

int

The index of the item.

Returns

A UIElement that corresponds to the item at the specified index. If the item is not realized, a new UIElement is created.

Remarks

This method does two things:

  1. Gets a UIElement that corresponds to the item in the data source at the specified index. If necessary, this method causes a virtualized item to be realized and creates a new UIElement for it.
  2. Queues that element on the next layout pass as the suggested anchor for the layout to use as a starting point.

Applies to

See also