Add ListView ScrollIntoView and ListViewPersistenceHelper samples#2179
Open
niels9001 wants to merge 4 commits into
Open
Add ListView ScrollIntoView and ListViewPersistenceHelper samples#2179niels9001 wants to merge 4 commits into
niels9001 wants to merge 4 commits into
Conversation
Two new ControlExamples on the ListView samples page, based on the UWP XamlListView reference sample: - ScrollIntoView: NumberBox + alignment ComboBox drive ListView.ScrollIntoView with ScrollIntoViewAlignment.Default or Leading. - Save/restore scroll position: demonstrates ListViewPersistenceHelper.GetRelativeScrollPosition and SetRelativeScrollPositionAsync, the same API a real app would use to restore position after navigating away and back. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Items are prefixed with their 1-based index (e.g. '1. John Doe') so it is easy to verify save/restore and ScrollIntoView landed on the expected entry. - NumberBox now sets Maximum, SmallChange/LargeChange, and ValidationMode so manually typed indices are preserved instead of reverting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
marcelwgn
approved these changes
May 29, 2026
Contributor
marcelwgn
left a comment
There was a problem hiding this comment.
Besides the showing of the raw position blob, LGTM!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two new
ControlExamplesections to the ListView samples page, adapted from the UWPXamlListViewreference sample.1. Save / restore scroll position
Demonstrates
ListViewPersistenceHelper.GetRelativeScrollPositionandSetRelativeScrollPositionAsync- the same API used to restore a ListView's scroll position after navigating away and back. Surfaced inline as Save position / Restore position buttons (and the captured opaque position string) so the behavior is observable inside a singleControlExample.2. ScrollIntoView
NumberBoxfor the target index and aComboBoxforScrollIntoViewAlignment(DefaultvsLeading) driveListView.ScrollIntoView.Changes
WinUIGallery/Samples/ListView/ListViewPage.xaml- two newControlExampleblocks.WinUIGallery/Samples/ListView/ListViewPage.xaml.cs- new collections,OnNavigatedToseeding, and handlers for the two samples.WinUIGallery/Samples/ListView/ListviewRestoreScrollPosition.txt- displayed snippet.WinUIGallery/Samples/ListView/ListviewScrollIntoView.txt- displayed snippet.Builds clean on x64 Debug.