Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] ListView Scrolled event doesn't reset ScrollY when clearing ItemsSource #8305

Open
simon10says opened this issue Oct 30, 2019 · 2 comments
Labels
a/listview Problems with the ListView/TableView e/2 🕑 2 good first issue hackathon help wanted We welcome community contributions to any issue, but these might be a good place to start! in-progress This issue has an associated pull request that may resolve it! inactive Issue is older than 6 months and needs to be retested p/Android t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@simon10says
Copy link

Description

Not sure if this is a bug or what, but when you clear the listview's ItemsSource, the Scrolled event's coordinate doesn't reset to 0

Steps to Reproduce

Referring to the enclosed project:

  1. Scroll down the list view and take note of the ScrollY value
    InShot_20191030_213157753

  2. Click on the Clear button to clear the ItemsSource

  3. Click on the Add button to add items to the ItemsSource

Expected Behavior

The ScrollY should be reset to 0 when ItemsSource is cleared

Actual Behavior

The ScrollY resume from the previous value

Basic Information

  • Version with issue:
  • IDE: Visual Studio 2019 Community 16.3.4
  • Platform Target Frameworks:
    • Android: 10.0.3.0
  • Nuget Packages: Xamarin Form 4.3.0.947036

Reproduction Link

App3.zip

@simon10says simon10says added s/unverified New report that has yet to be verified t/bug 🐛 labels Oct 30, 2019
@pauldipietro pauldipietro added this to New in Triage Oct 30, 2019
@hartez hartez added a/listview Problems with the ListView/TableView p/Android e/2 🕑 2 and removed s/unverified New report that has yet to be verified labels Oct 30, 2019
@hartez hartez added this to To do in Android Ready For Work via automation Oct 30, 2019
@hartez hartez removed this from New in Triage Oct 30, 2019
@simon10says
Copy link
Author

Another observation:

  1. scroll down the list and take note of the scrollY (pos1)
  2. create a button and in the code-behind, clear enough items so that the remaining items fit into the listview (no scroll)
  3. Click on the Add button to re-populate the items
  4. The starting scrollY value starts from pos1 instead of 0

@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! and removed inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! labels Jul 17, 2020
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! good first issue and removed inactive Issue is older than 6 months and needs to be retested labels Jul 31, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
rihadavid added a commit to rihadavid/Xamarin.Forms that referenced this issue Sep 7, 2020
Fixes xamarin#8305 and xamarin#9370 and another bug that has not been reported - changing height of the first row also creates incorrect ScrollY value.
Not 100% sure if there can't be any other situation when the scroll fails to be tracked, for which setting the  `_contentOffset` to `0` might not be correct, but it fixes the "reloaded ItemsSource" issue, which seems to be the most common. When we were not able to track the offset at all, it's a bug anyway, so setting the offset to 0 seems good because it solves this issue at least.
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Sep 8, 2020
@samhouts samhouts moved this from To do to In progress in Android Ready For Work Sep 8, 2020
@samhouts samhouts added the inactive Issue is older than 6 months and needs to be retested label Sep 18, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@samhouts samhouts added this to In Progress in vNext+1 (5.0.0) Nov 3, 2020
@PureWeen PureWeen added this to To do in v5.0.1 via automation Nov 5, 2020
@PureWeen PureWeen removed this from In Progress in vNext+1 (5.0.0) Nov 5, 2020
@samhouts samhouts added this to In Progress in vNext+1 (5.0.0) Nov 5, 2020
@samhouts samhouts removed this from To do in v5.0.1 Nov 5, 2020
@PureWeen PureWeen added this to To do in v5.0.1 via automation Nov 5, 2020
@PureWeen PureWeen removed this from In Progress in vNext+1 (5.0.0) Nov 5, 2020
@boris-df
Copy link

boris-df commented Apr 6, 2022

it also seems to be a problem with the scroll-position in the scrolled-event, if you make a ".ScrollTo(...)" ...
I see the problem that the e.ScrollY is for example 2972 but i'm on the top of list!
bummer :'(

any workaround availble / can i fix that in an own renderer or something?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/listview Problems with the ListView/TableView e/2 🕑 2 good first issue hackathon help wanted We welcome community contributions to any issue, but these might be a good place to start! in-progress This issue has an associated pull request that may resolve it! inactive Issue is older than 6 months and needs to be retested p/Android t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
Android Ready For Work
  
In progress
v5.0.1
To do
4 participants