Skip to content

ScrollViewer.ExtentWidth/ExtentHeight ignore ZoomFactor, unlike WinUI #26426

Open

Description

@MartinZikmund

Current behavior

Severity: Low - code that derives thumb sizes, "fit" or scroll percentages from ExtentWidth/ExtentHeight gets wrong numbers while zoomed (maps, image/PDF viewers); nothing crashes.

With ZoomMode="Enabled" and a ZoomFactor other than 1, ScrollViewer.ExtentWidth/ExtentHeight stay at the unscaled content size, while ScrollableWidth/ScrollableHeight already include the zoom. So ExtentHeight - ViewportHeight != ScrollableHeight. The UIA Scroll pattern view size is derived from the extent, so it is wrong too.

Expected behavior

As in WinUI, the extent is reported in zoomed coordinates: ExtentHeight = content height * ZoomFactor.

Measured on native WinUI (WinAppSDK 2.5.1) vs Uno, 300x300 viewer, 400x400 content:

zoom 2   : WinUI ExtentHeight=800  ScrollableHeight=500   Uno ExtentHeight=400  ScrollableHeight=500
zoom 4   : WinUI ExtentHeight=1600 ScrollableHeight=1300  Uno ExtentHeight=400  ScrollableHeight=1300
zoom 0.5 : WinUI ExtentHeight=200                         Uno ExtentHeight=400
UIA VerticalViewSize at zoom 3: WinUI 25, Uno 75

(The WinUI numbers come from a native WinUI repro, not from the C++ sources.)

How to reproduce it

  1. Create a ScrollViewer, host it in the window, wait for layout, then zoom:
var sv = new ScrollViewer
{
    Width = 300, Height = 300,
    ZoomMode = ZoomMode.Enabled, MinZoomFactor = 0.5f, MaxZoomFactor = 4,
    HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
    VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
    Content = new Border { Width = 400, Height = 400 },
};
// put it in the window, wait for layout
sv.ChangeView(null, null, 2f, true);
// wait until sv.ZoomFactor == 2
// WinUI: ExtentHeight=800, ScrollableHeight=500
// Uno:   ExtentHeight=400, ScrollableHeight=500

Runtime-verified with a runtime test on Skia desktop (Win32), master 46ea872727d: ScrollableHeight is 500 as expected, ExtentHeight is 400 instead of 800.

Workaround

Multiply the extent by ZoomFactor yourself.

Works on UWP/WinUI

Yes (see numbers above).

Environment

Nuget Package: master 46ea872727d (net11.0-desktop)

Affected platforms

Skia (managed ScrollViewer), reproduced on Skia desktop (Win32).

Anything else

Root cause (source-backed): ScrollViewer.UpdateDimensionProperties publishes the unscaled content size as ExtentWidth/ExtentHeight, then multiplies by ZoomFactor only for ScrollableWidth/ScrollableHeight:

if (_presenter?.CustomContentExtent is { } customExtent)
{
ExtentHeight = customExtent.Height;
ExtentWidth = customExtent.Width;
}
else if (Content is FrameworkElement fe)
{
ExtentHeight = CalculateExtent(this, fe, isHorizontal: false);
ExtentWidth = CalculateExtent(this, fe, isHorizontal: true);

var scaledExtentHeight = ExtentHeight * ZoomFactor;
var scaledExtentWidth = ExtentWidth * ZoomFactor;
var scrollableHeight = Math.Max(Math.Round(scaledExtentHeight - ViewportHeight, 4), 0);
ScrollableHeight = scrollableHeight;
var scrollableWidth = Math.Max(Math.Round(scaledExtentWidth - ViewportWidth, 4), 0);

ScrollContentPresenter also multiplies its own copy of the extent by the zoom factor, so a fix must keep the presenter on the unscaled value to avoid scaling twice.

Related ScrollViewer issues: #26403, #26404.

Activity

  1. added
    kind/bug
    triage/untriaged
    area/skia ✏️
    area/scrollviewer ⏬
    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/bugtriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions