Skip to content

ScrollViewer with ScrollBarVisibility=Disabled still reports the content extent and scrolls (ChangeView, UIA, default horizontal ListView) #26403

Open

Description

@MartinZikmund

Current behavior

Severity: Medium - A direction set to ScrollBarVisibility.Disabled still reports the full content extent, scrolls through ChangeView, and tells UIA it is scrollable; content that WinUI clips becomes scrollable (most visibly a default horizontal ListView).

With HorizontalScrollBarVisibility="Disabled", a ScrollViewer on Skia still:

  • reports the content's full width as ExtentWidth (so ScrollableWidth > 0),
  • applies a horizontal offset requested through ChangeView,
  • reports HorizontallyScrollable == true through the UIA Scroll pattern.

Observed on master 46ea872727d (net11.0-desktop, Skia/Win32): a 300x300 ScrollViewer with a 2000x3000 child gives ExtentWidth=2000, ViewportWidth=300, ScrollableWidth=1700, and ChangeView(500, 500, null, true) returns true with HorizontalOffset=500.

A related and more visible case is a default ListView with a horizontal ItemsStackPanel. The default ListView template disables horizontal scrolling, so in WinUI such a list is clipped unless the app opts in. On Uno it scrolls horizontally (ExtentWidth 10400, ScrollableWidth 9614.7 in the comparison run).

Expected behavior

In WinUI a Disabled direction cannot scroll. The ScrollContentPresenter measures its child against the viewport in that direction, so ExtentWidth == ViewportWidth, ScrollableWidth == 0, ChangeView leaves that offset at 0, and UIA reports HorizontallyScrollable == false.

WinUI side-by-side results (WinAppSDK 2.5.1, same XAML/C# repro) versus Uno:

hDisabled (2000x3000 child)   WinUI: ExtentWidth=300  ScrollableWidth=0     Uno: 2000 / 1700
ChangeView(500,500)           WinUI: V=500 H=0                              Uno: V=500 H=500
UIA Scroll pattern            WinUI: HorizontallyScrollable=False, Vertically=True   Uno: True / True
both Disabled, 5000x5000      WinUI: extent 300x300, ChangeView returns False        Uno: extent 5000, ChangeView returns True
ListView + horizontal ItemsStackPanel (default template)
                              WinUI: ExtentWidth=784.7 ScrollableWidth=0    Uno: 10400 / 9614.7

WinUI source backing this (dxaml/xcp/dxaml/lib/ScrollContentPresenter_Partial.cpp in microsoft-ui-xaml): measure gives the child an infinite width only if (pScrollData->m_canHorizontallyScroll) (~line 1762), and the computed offset is reset to 0 when !m_canHorizontallyScroll (~lines 3209-3215, "Reset the horizontal offset when m_canHorizontallyScroll becomes False").

How to reproduce it

  1. Create a Skia desktop app (or add this as a runtime test).
  2. Host this in a window:
var sv = new ScrollViewer
{
    Width = 300,
    Height = 300,
    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
    VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
    Content = new Border { Width = 2000, Height = 3000 },
};
// host in the window, wait for loaded + idle
var ok = sv.ChangeView(500, 500, null, true);
// wait for idle, then read:
// sv.ExtentWidth, sv.ScrollableWidth, sv.HorizontalOffset, ok
  1. Observe ExtentWidth=2000, ScrollableWidth=1700, ok=true, HorizontalOffset=500. WinUI gives ExtentWidth=300, ScrollableWidth=0, HorizontalOffset=0.
  2. For the ListView case: new ListView { Width = 400, Height = 200, ItemsPanel = <ItemsStackPanel Orientation="Horizontal"> } with a few hundred items and the default template. WinUI is clipped (no horizontal scroll), Uno scrolls.

Workaround

Constrain the content width yourself (for example bind its Width to the ScrollViewer's viewport width), or for ListView use a template that enables horizontal scrolling deliberately.

Works on UWP/WinUI

  • UWP
  • WinUI

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

master 46ea872727d (built from source, Debug, net11.0-desktop). The same result was seen earlier on master 4636b705e97; no changes to ScrollViewer or ScrollContentPresenter between the two.

Affected platforms

Skia (Desktop). Observed on Win32; the code involved is the managed ScrollContentPresenter/ScrollViewer shared by the Skia heads.

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

What was verified how:

  • Uno numbers: runtime-verified with a runtime test on net11.0-desktop at master 46ea872727d.
  • WinUI numbers: runtime-verified against a native WinUI 3 app (WinAppSDK 2.5.1) during an earlier comparison run; the ListView row came from the same run.
  • Root cause: source reading.

Root cause on master: ScrollViewer does compute CanHorizontallyScroll = false for Disabled
(src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs, UpdateComputedHorizontalScrollability, _presenter.CanHorizontallyScroll = allowed;), but nothing else honors it:

  • the extent is taken from the content regardless of CanHorizontallyScroll (the child is not measured against the viewport in that direction);
  • ScrollContentPresenter.Managed.cs clamps offsets against ScrollableWidth without checking CanHorizontallyScroll, so ChangeView and BringIntoView can move the content.

A fix probably means (a) measuring the child with the viewport width when horizontal scrolling is disabled, as WinUI does, and (b) forcing the horizontal offset to 0 in that case. The same applies to the vertical direction.

Activity

  1. added
    kind/bug
    triage/untriaged
    area/skia ✏️
    project/layout 🧱
    area/scrollviewer ⏬
    project/items 🧾
    difficulty/medium 🤔
    on Nov 13, 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/scrollviewer ⏬area/skia ✏️difficulty/medium 🤔kind/bugproject/items 🧾project/layout 🧱triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions