xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] CarouselView stops calling PositionChanged/CurrentItemChanged #14265

Open BlueRaja opened 3 years ago

BlueRaja commented 3 years ago

Description

When ItemsSource is set to a binding, PositionChanged and CurrentItemChanged will both stopped being called the second time the binding is updated (so, the third overall value given to ItemsSource).

They work initially, and work the first time ItemsSource is changed, but the second time both break.

Repro steps

  1. Bind ItemsSource to a list with two values, with Loop = false
  2. Update the value the control is bound to to a new list, twice
  3. Scroll the carousel view, or call ScrollTo

Expected: PositionChanged and CurrentItemChanged events are raised
Actual: Neither event is ever raised again, no matter what you do. The Position property will forever be equal to 0.

Basic Information

Workaround

None that I can find

Domik234 commented 3 years ago

Hey, I've tried and same problem.

Note: IndicatorView isn't updated too when Loop = false is set. Note 2:

<StackLayout Spacing="0">
  <Frame>
    <Label Text="Test" />
  </Frame>
  <Image Source="test_image" />
</StackLayout>

I've tried to add TapGesture for StackLayout to navigate to next page. When I navigated back and forward few times, the frame was not visible and whole CarouselView had wrong height. This happened only on iOS.

EBusch commented 3 years ago

I've been running into this a bit as well, I did find something that may help to lead to solving this issue. After I navigate away from a page with an indicator and then return to it I am finding the values contained in ItemsViewScrolledEventArgs are incorrect. My HorizontalOffset has a big amount added to the actual value (in my case instead of zero it reads 785.090909090909. Meanwhile CenterItemIndex, FirstVisibleItemIndex and LastVisibleItemIndex are all -1 and HorizontalDelta is -36.

I hope this can help lead to a fix!

xxpp123zz commented 2 years ago

I have a similar problem,when i change CarouselView.Loop as False,after i change CarouselView.ItemsSource twice,The PositionChangedEvent is does't work,and the position won't change.

I tried many times,the point is Loop if somebody want solve it,change the Loop of Carouselview as True is my suggestion.

meanwhile,i find some problem in CarouselView of custom view when the CarouselView's Loop is True I hope this bug can be resolved as soon as possible