Share via


VirtualizingLayoutContext.GetOrCreateElementAtCore 方法

定義

在衍生類別中實作時,擷取 UIElement ,代表使用指定選項在指定索引中找到的來來源資料項。

本檔適用于 Windows 應用程式 SDK 中適用于 WinUI 的 WinUI 2 for UWP (,請參閱Windows 應用程式 SDK命名空間) 。

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

參數

index
Int32

int

要擷取 UIElement 的資料項目索引。

options
ElementRealizationOptions

指定是否要隱藏擷取之專案的自動回收,還是強制建立新元素。

傳回

表示資料項目的 UIElement

備註

這個方法是由 GetOrCreateElementAt (System.Int32) GetOrCreateElementAt (System.Int32,Microsoft.UI.Xaml.Controls.ElementRealizationOptions) 呼叫。

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

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

適用於