ListViewPersistenceHelper 類別

定義

表示協助程式類別,用來儲存及擷取 ListView的相對捲動位置。

public ref class ListViewPersistenceHelper sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ListViewPersistenceHelper final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ListViewPersistenceHelper
Public NotInheritable Class ListViewPersistenceHelper
繼承
Object Platform::Object IInspectable ListViewPersistenceHelper
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

如需完整的實作,請參閱ListView 和 GridView 範例存放庫中的 [還原捲動位置範例 https://github.com/microsoft/Windows-universal-samples/blob/main/Samples/XamlListView/cs/Scenario5_RestoreScrollPosition.xaml.cs) ]。

備註

如果 ItemsStackPanel.ItemsUpdatingScrollMode 屬性設定為 KeepItemsInView,ListViewPersistenceHelper 會嘗試使用第一個可見專案的索引鍵來還原捲動位置。 如果 ItemsUpdatingScrollModeKeepLastItemInView,它會嘗試使用最後一個可見專案的索引鍵來還原捲動位置。

方法

GetRelativeScrollPosition(ListViewBase, ListViewItemToKeyHandler)

擷取 ListView的相對捲動位置。

SetRelativeScrollPositionAsync(ListViewBase, String, ListViewKeyToItemHandler)

開始非同步動作,以設定 ListView的相對捲動位置。

適用於