Skip to content

ScrollView scrollbars do not disappear when zoomed to fit with no animation #11076

@joelspadin

Description

@joelspadin

Describe the bug

I have a ScrollView displaying an image that is larger than the viewport and with the scrollbar visibilities in both directions set to auto. When loading the image, I call ZoomTo() with ScrollingAnimationMode.Disabled to set the initial zoom to fit the viewport. The content fully fits within the view, but the scrollbars do not disappear despite not being able to scroll. If I allow it to animate, then the scrollbars disappear, but the animation is distracting.

Why is this important?

Having the scrollbar still visible despite not being able to scroll is confusing.

Steps to reproduce the bug

  1. Create a page containing
<ScrollView
	x:Name="ScrollView"
	ZoomMode="Enabled"
	HorizontalScrollMode="Auto"
	HorizontalScrollBarVisibility="Auto"
	VerticalScrollMode="Auto"
	VerticalScrollBarVisibility="Auto"
>
	<Image x:Name="Image" />
</ScrollView>
  1. In the .cs file, add
var image = // load a SoftwareBitmap that is larger than the ScrollView
var source = new SoftwareBitmapSource();
await source.SetBitmapAsync(image);

Image.Width = image.PixelWidth;
Image.Height = image.PixelHeight;
Image.Source = source;

// Fit the image to a slightly smaller size than the view to make sure
// rounding error doesn't result in it being slightly bigger.
var scale = (float)Math.Min(
    (ScrollView.ActualWidth - 2) / image.PixelWidth, 
    (ScrollView.ActualHeight - 2) / image.PixelHeight
);

ScrollView.ZoomTo(scale, null, new ScrollingZoomOptions(ScrollingAnimationMode.Disabled));

Actual behavior

The ScrollView immediately zooms to fit the image, but the scrollbars still appear as if the image was at its original zoom level. It is not possible to scroll by grabbing the scrollbar handles or using the mouse wheel, but clicking on one of the arrows on the scrollbars causes it to briefly scroll in that direction, and then the scrollbars disappear and it recenters the image in the view. Zooming out further also makes the scrollbars disappear.

Expected behavior

The scrollbars should disappear, since it is not possible to scroll.

Screenshots

This is a 2048 x 2048 black image drawn inside a much smaller ScrollView (with magenta background) and zoomed to fit as described above.

Image

NuGet package version

1.8.260416003

Windows version

Windows 11 (24H2): Build 26100

Additional context

If new ScrollingZoomOptions(ScrollingAnimationMode.Disabled) is removed from the code, it zooms out from the upper left corner of the image, and the scrollbar disappear as expected. This initial zoom is distracting though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageIssue needs to be triaged by the area owners

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions