Share via


VirtualizingLayoutContext.GetOrCreateElementAt 方法

定義

多載

GetOrCreateElementAt(Int32)

擷取 UIElement,代表在指定索引處找到的來源數據項。 根據預設,如果項目已經存在,則會傳回它;否則,會建立新的專案。

GetOrCreateElementAt(Int32, ElementRealizationOptions)

使用指定的選項,擷取 UIElement,代表在指定索引中找到的來源數據項。

GetOrCreateElementAt(Int32)

擷取 UIElement,代表在指定索引處找到的來源數據項。 根據預設,如果項目已經存在,則會傳回它;否則,會建立新的專案。

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

參數

index
Int32

int

要擷取 UIElement 的數據項索引。

傳回

表示數據項的 UIElement。

屬性

備註

此方法會呼叫 GetOrCreateElementAtCore (System.Int32,Microsoft.UI.Xaml.Controls.ElementRealizationOptions) ,並將選項設定為 None

GetElementAtCore 必須在衍生類別中實作。

適用於

GetOrCreateElementAt(Int32, ElementRealizationOptions)

使用指定的選項,擷取 UIElement,代表在指定索引中找到的來源數據項。

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

參數

index
Int32

int

要擷取 UIElement 的數據項索引。

options
ElementRealizationOptions

ElementRealizationOptions 的值,指定是否要隱藏擷取之項目的自動回收,或強制建立新元素。

傳回

表示數據項的 UIElement。

屬性

備註

這個方法會呼叫 GetOrCreateElementAtCore (System.Int32,Microsoft.UI.Xaml.Controls.ElementRealizationOptions) ,這必須在衍生類別中實作。

當您要求指定索引的專案時,您可以選擇性地指定是否要隱藏擷取項目的自動回收,或強制建立新元素。 使用自動回收所擷取的專案會隱藏 (SuppressAutoRecycle) 遭到忽略,此邏輯會清除未在目前版面配置階段中擷取的已實現元素。 您必須將這些項目傳遞至 RecycleElement 方法來明確回收這些專案,以避免記憶體流失。

這些選項適用於更進階的配置,選擇明確地管理元素的實現和回收作為效能優化。

適用於