Bug 36651 - ScrollToAsync fails to scroll on Windows Phone 8.1 RT
Summary: ScrollToAsync fails to scroll on Windows Phone 8.1 RT
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.0.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Paul DiPietro [MSFT]
URL:
: 57739 ()
Depends on:
Blocks:
 
Reported: 2015-12-05 16:28 UTC by John Hardman
Modified: 2017-11-08 12:44 UTC (History)
8 users (show)

Tags: Windows WinPhone 8.1 ScrollView ScrollToAsync ac fr
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description John Hardman 2015-12-05 16:28:32 UTC
With a ScrollView containing a StackLayout, when based on user interaction I add new elements to that StackLayout, I use ScrollToAsync to automatically scroll to one of the newly added items. On Android and iOS, this works as expected. On Windows Phone 8.1 RT, the expected scroll simply does not happen.
Comment 1 John Hardman 2015-12-10 23:07:20 UTC
I've adapted the Xamarin-produced code from bug 34909 to demonstrate 36651. When run on Windows 8.1 RT, the call to ScrollToAsync does not scroll the ScrollView. On Android and iOS this works as expected. On Windows, it does not. Simply run this and press the "Add item" button a few times.
(Note that if you keep pressing it you will get a Layout Cycle Detected exception eventually, but that's a different issue).

using System;

using Xamarin.Forms;

namespace ZyaMusic_ScrollViewBug
{
    public class LandingPage : ContentPage
    {
        private static int numberOfButtons = 3;
        StackLayout layout;
        Button addItem, removeItem;
        ScrollView scrollView;

        public LandingPage()
        {
            layout = new StackLayout();
            for (var i = 0; i < 10; i++)
            {
                layout.Children.Add(new Button { Text = "This is a button" });
            }

            addItem = new Button { Text = "Add Item" };
            removeItem = new Button { Text = "Remove Item" };
            scrollView = new ScrollView { Content = layout };

            Content = new StackLayout
            {
                Children = { scrollView, addItem, removeItem }
            };

            addItem.Clicked += (object sender, EventArgs e) =>
            {
                Button lastButton = null;
                for (int i = 0; i < numberOfButtons; ++i)
                {
                    lastButton = new Button
                    {
                        Text = String.Format("This is button #{0}", i)
                    };
                    layout.Children.Add(lastButton);
                }
                ++numberOfButtons;

            scrollView.ScrollToAsync(lastButton, ScrollToPosition.End, false);
            };
            removeItem.Clicked += (object sender, EventArgs e) =>
            {
                if (layout.Children.Count != 0)
                    layout.Children.RemoveAt(layout.Children.Count - 1);
            };
        }
    }
}
Comment 2 John Miller [MSFT] 2016-01-04 17:33:01 UTC
I was not able to reproduce this. It seems similar to my results on https://bugzilla.xamarin.com/show_bug.cgi?id=32213. Could you upload a full project that I can use to reproduce this?
Comment 3 Chris King 2016-04-14 01:40:25 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
 
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team
Comment 4 John Hardman 2016-11-18 18:23:04 UTC
Apologies for the delay in replying. I've just re-tested this on both WinRT 8.1 and UWP, using XF 2.3.2.127 . The problem still exists - it's fine on Android (probably on iOS too, but an update yesterday broke my iOS build system), but on WinRT 8.1 and UWP, it still fails.

I just added the code above to an existing solution, instantiated an object of type LandingPage and pushed it onto the navigation stack, as follows:
                  
await Navigation.PushAsync(new LandingPage());

Run the code, push that page. You will see a load of buttons, with an add button and a remove button at the bottom. Press the add button until the number of buttons above the add button is such that a vertical scroll bar appears. Note that the add and remove buttons are not in the scrollable view, so the scroll bar is for the collection of buttons above the add button. When the add button is pressed, the scrollable collection above should scroll so that the last of the newly added buttons is always displayed. This does not happen on WinRT 8.1 or UWP. The scroll does not happen.

There are multiple scroll bugs in Bugzilla now, so there may be duplication at this point. However, the code above is a quick way of showing the problem.
Comment 5 Paul DiPietro [MSFT] 2017-06-26 15:30:25 UTC
*** Bug 57739 has been marked as a duplicate of this bug. ***
Comment 6 Samantha Houts [MSFT] 2017-09-11 20:36:08 UTC
https://github.com/xamarin/Xamarin.Forms/pull/988
Comment 7 Rui Marinho 2017-11-08 12:44:39 UTC
Should be fixed on 2.5.1-pre1