ScrollView nested within deep Grid hierachy not displaying

Hello

I am working with Xamarin.Forms 2.3.0.107 (WP 8.1) and realized that a ScrollView which is nested within a Grid (which is itself nested in a Grid) is not displaying:

// this is not working in WP8.1 (ScrollView not displayed), but it works for iOS and Android
MainPage -> ContentPage -> Grid -> Grid ->ScrollView -> StackLayout

// this is working also for WP8.1
MainPage -> ContentPage -> Grid ->ScrollView -> StackLayout

It used to work in Xamarin.Forms 1.3

This behaviour can easily be reproduced:
1. Create a Blank WP8.1 Project; add Xamarin.Forms
2. Replace the MainPage.xaml constructor with the following code:

    // Constructor
    public MainPage()
    {
        InitializeComponent();

        StackLayout stackLayout = new StackLayout
        {
            Spacing = 0,
            VerticalOptions = LayoutOptions.FillAndExpand,
            Children = 
            {
                new Label
                {
                    Text = "Test",
                    HorizontalOptions = LayoutOptions.Start
                },

            }
        };

        Xamarin.Forms.Grid g1 = new Xamarin.Forms.Grid();

        Xamarin.Forms.Grid g2 = new Xamarin.Forms.Grid();
        g1.Children.Add(g2);

        ScrollView scrollView = new ScrollView();
        scrollView.Orientation = ScrollOrientation.Vertical;
        scrollView.Content = stackLayout;

        g2.Children.Add(scrollView);

        ContentPage p = new ContentPage()
        {
            Content= g1
        };


        Xamarin.Forms.Forms.Init();
        Content = p.ConvertPageToUIElement(this);
    }

Does anybody have any ideas here? Is it a known bug? I already tried various VerticalOptions but never succeeded?!
Thank you!

Answers

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @FriedrichWedel - that looks like a bug but not any that I know of.

    Submit a bug report at http://bugzilla.xamarin.com with the reproduction example attached and someone from Xamarin will eventually look at it. However there is no guaranteed timeline for a fix, so I would suggest trying to find a workaround in the meantime if possible.

    Or if you are that way inclined, download the source code, fix the bug yourself and submit a PR.

  • FriedrichWedelFriedrichWedel CHMember ✭✭

    Thank you, I just found out there is already a bug report:
    https://bugzilla.xamarin.com/show_bug.cgi?id=42501

  • INDICEINDICE GRMember

    Hi all, we're facing the same issue here - any news on resolving this issue or workaround ?

  • INDICEINDICE GRMember

    I got a temp solution hope it helps.
    I added a renderer - overrided MeasureOverride and called the native's control ApplyTemplate method;
    the scrollviewer with it;'s content is now rendered.


    public class ScrollViewerRenderer : Xamarin.Forms.Platform.WinPhone.ScrollViewRenderer {
    protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize) {
    this.Control.ApplyTemplate();
    return base.MeasureOverride(availableSize);
    }
    }

  • RolandHuhnRolandHuhn USMember ✭✭

    @INDICE help me.
    Thank you, you are a life saver.

Sign In or Register to comment.