Skip to content

[iOS] Scrollviewer not scrolling #11558

@Larhei

Description

@Larhei

Description

When changing the ContentSize of the Scrollable content in Scrollviewer after OnLoad, the Scrollview does not Scroll.

Lets say I need a scrollable ItemsControl.
I would use a ScrollViewer containing a BindableLayout.
When for what ever reason it takes longer to generate the Collection bound to the Itemssource and the generated Items are greater than the ViewPort of the ScrollView, after rendering the items, the Scrollviewer does not scroll.

Steps to Reproduce

  1. Just run the demo on iOS

Link to public reproduction project repository

https://github.com/Larhei/Maui-Issues/tree/main/ScrollViewer/ScrollViewer

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS all

Did you find any workaround?

Subscribing the SizeChanged of the BindableLayout and setting the MinimHeightRequest helps.
Forcing an additional Measure to get it right is not my Job.

private void HandleSizeChanged(object sender, System.EventArgs e)
{
    var layout = sender as Layout;
    if (layout == null)
    {
        return;
    }
    layout.MinimumHeightRequest = 0;
    var size = layout.Measure(double.PositiveInfinity, double.PositiveInfinity, MeasureFlags.None);
    if (double.IsNaN(size.Request.Height) || double.IsInfinity(size.Request.Height))
    {
        return;
    }

    layout.MinimumHeightRequest = Math.Max(size.Request.Height, size.Minimum.Height);
}

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions