Skip to content

ItemsView shows no items after ItemsSource shrinks while scrolled to the end (Skia) #25462

Open

Description

@MartinZikmund

Current behavior 🐛

On Skia Desktop, an ItemsView goes blank when its ItemsSource is replaced with a shorter list while it is scrolled near the end. The inner ScrollPresenter's extent shrinks, but the vertical offset keeps its old value (beyond the new extent), so the realized items sit outside the viewport.

Measured in a runtime test (100 items, 100 px high ItemContainers, 300 px high ItemsView, default StackLayout):

before scroll : realized=6, visible in viewport=3
scrolled to end: VerticalOffset=9700, realized=7, visible=3
ItemsSource = 8 items: VerticalOffset=9700 (unchanged), ExtentHeight=800, realized=7, visible=0   <-- blank

The offset 9700 is larger than the new maximum (800 - 300 = 500), so nothing is visible. Swapping back to the long list shows the old bottom position again. Doing the same swap while scrolled to the top works.

This is not specific to LinedFlowLayout: it reproduces with the default StackLayout. I did not manage to get a clean scrolled-to-end state with LinedFlowLayout in the test, so that layout is unverified.

Expected behavior 🎯

Like WinUI, the offset is pulled back into range when the extent shrinks, so the last items of the new list are shown (here offset 500).

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Create an ItemsView (default layout), Height="300", with a template whose root is an ItemContainer of height 100, and ItemsSource = 100 ints.
  2. Scroll to the end: itemsView.ScrollView.ScrollTo(0, 100000, new ScrollingScrollOptions(ScrollingAnimationMode.Disabled)); (mouse wheel gives the same result).
  3. Set itemsView.ItemsSource to a list of 8 ints.
  4. Wait for idle. itemsView.ScrollView.VerticalOffset is still 9700 while ExtentHeight is 800, and no item is inside the viewport.
var sut = new ItemsView { Width = 400, Height = 300, ItemsSource = Enumerable.Range(0, 100).ToList(), ItemTemplate = template };
await UITestHelper.Load(sut, x => x.IsLoaded);
sut.ScrollView.ScrollTo(0, 100000, new ScrollingScrollOptions(ScrollingAnimationMode.Disabled));
await UITestHelper.WaitForIdle();
sut.ItemsSource = Enumerable.Range(0, 8).ToList();
await UITestHelper.WaitForIdle();
// sut.ScrollView.VerticalOffset == 9700, ExtentHeight == 800

Workaround 🛠️

Scroll to the top before swapping the source: itemsView.ScrollView?.ScrollTo(0, 0, new ScrollingScrollOptions(ScrollingAnimationMode.Disabled)).

Works on UWP/WinUI

  • WinUI (by code inspection, not by a native run)

Environment

  • Nuget Package: master at 4393a80 (also seen on Uno.WinUI 7.0.0-dev.2282)

NuGet package version(s) 📦

master 4393a80, Uno.WinUI 7.0.0-dev.2282

Affected platforms 📱💻🖥️

Skia Desktop (Win32 verified at runtime). Other Skia heads share the same code but were not run.

Anything else we need to know? 💬

Root cause (code inspection, confirmed by the runtime numbers above): InteractionTracker only clamps Position to MinPosition/MaxPosition inside its set-position paths (e.g. SetScale). When ScrollPresenter updates MaxPosition through its expression animation after the extent shrinks, SetAnimatableProperty just stores the new MaxPosition and never re-clamps the current Position.

WinUI's ScrollPresenter has the "ExtentHeight shrank while overpanning" handling (ScrollPresenter.cpp, ArrangeOverride, the edge anchoring block, ported in Uno at ScrollPresenter.cs#L860) but no explicit offset clamp, so it relies on the compositor InteractionTracker keeping Position within the bounds. The compositor is closed source, so this part is inferred, not proven.

Suggested fix: re-clamp Position (and raise ValuesChanged) when MinPosition/MaxPosition change.

Activity

  1. added
    kind/bug
    triage/untriaged
    area/skia ✏️
    area/scrollviewer ⏬
    project/items 🧾
    area/items-repeater
    difficulty/medium 🤔
    on Oct 14, 2026
  2. removed
    triage/untriaged
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/items-repeaterarea/scrollviewer ⏬area/skia ✏️difficulty/medium 🤔kind/bugproject/items 🧾

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions