Bug 60712 - ListView auto scrolling to top in iOS when the ItemsSource is updated, works fine in Android.
Summary: ListView auto scrolling to top in iOS when the ItemsSource is updated, works ...
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.5.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-11-16 09:31 UTC by Peter Zosiak
Modified: 2018-03-08 09:07 UTC (History)
3 users (show)

Tags: listview, scroll, ac
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 for Bug 60712 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Peter Zosiak 2017-11-16 09:31:46 UTC
when ItemSource is updated on ListView, Listview scroll to first item automatically. Its just on iOS (works fine on Android and UWP)

Regarding to this topic : https://forums.xamarin.com/discussion/comment/306715
Video : https://www.youtube.com/watch?v=kovFbP1o9_E

Code behind: 
XAML

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:behaviors="clr-namespace:Corcav.Behaviors;assembly=Corcav.Behaviors"
             xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
             xmlns:i18n="clr-namespace:MnamByNadia.Resources;assembly=MnamByNadia"
             x:Class="MnamByNadia.Pages.RecipesPage" x:Name="RecipesPage">
    <ContentPage.Content>
      
                <ListView 
                    BackgroundColor="Transparent" 
                    SelectedItem="{Binding SelectedItem, Mode=TwoWay}" 
                    HasUnevenRows="True" 
                    ItemsSource="{Binding Recipes}" 
                    CachingStrategy="RetainElement" 
                    SeparatorVisibility="None">
                    <behaviors:Interaction.Behaviors>
                        <behaviors:BehaviorCollection>
                            <behaviors:EventToCommand       EventName="ItemAppearing" 
                                                            Command="{Binding ItemAppearingCommand}" 
                                                            CommandParameter="{Binding Item.ItemAppearing}" 
                                                            PassEventArgument="True" 
                                                            CommandName="ItemAppearingCommand" 
                                                            />
                        </behaviors:BehaviorCollection>
                    </behaviors:Interaction.Behaviors>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                 <Image HeightRequest="360" Source="{Binding Img_Url_Preview}" />
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
       
    </ContentPage.Content>
</ContentPage>

Loading update for datasource

 public Task LoadData(int page, string query, string type)
        {
            var aaa = rs.GetRecipesAsync(page, query, type).ContinueWith(t =>
            {
                if (t.Status == TaskStatus.RanToCompletion)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        if (t.Result != null)
                        {
                            foreach (Recipe rec in t.Result)
                            {
                                if (!Recipes.Contains(rec))
                                    if (Recipes.IndexOf(rec) < 0)
                                        if (Recipes.Any(p => p.Key == rec.Key) == false)
                                            Recipes.Add(rec);
                            }
                            
                        }
                    });
                }
            });

            return null;

        }
Comment 1 Peter Zosiak 2017-11-16 09:35:09 UTC
Set RowHeight and HasUnevenRows="False" does help ONLY ON SIMULATORS, NOT on real iOS 11 devices.
Comment 2 Paul DiPietro [MSFT] 2017-11-20 03:16:05 UTC
Can you please upload a full reproduction project rather than incomplete snippets, removing any code which is unnecessary to reproduce the issue? A basic ListView with an ObservableCollection and HasUnevenRows=true (and the RetainElement strategy, to test) doesn't scroll the list to the top when adding an item using the current 2.5.0 stable build.
Comment 3 Peter Zosiak 2017-11-20 08:34:38 UTC
Sure, I created solution for you (hope OneDrive is ok for you)

https://1drv.ms/u/s!AkpHV3sID0DBmMdxhda6uRNgcTSlCA

I cut off all unnecessary code
Comment 4 Paul DiPietro [MSFT] 2017-12-18 16:48:24 UTC
The jumping seems a bit hit or miss (sometimes it goes more towards the middle, rather than the top), but I will confirm this until there can be further investigation.