Xamarin.forms: [Bug] CarouselView scrolls multiple times at a time after setting a position.

Created on 7 Nov 2019  ·  14Comments  ·  Source: xamarin/Xamarin.Forms

Description

After setting a position, CarouselView scolls multiple times at a time. This issue occurs only when you scroll the first time after changing the location.

<Button Clicked="Button_Clicked"/>
<CarouselView x:Name="carouselView" ...>
    <CarouselView.ItemTemplate>
        <DataTemplate>
            <StackLayout>
                ...
            </StackLayout>
        </DataTemplate>
    </CarouselView.ItemTemplate>
</CarouselView>
private void Button_Clicked(object sender, System.EventArgs e)
{
    carouselView.Position = 3;
}

Screenshots


carouselview 3 Android needs-info ❓ needs-repro ❔ bug

Most helpful comment

It's fixed ! I have updated the sample on XF 4.6.0.800 and i doesn't reproduce the issue.
Thank you very much !

All 14 comments

Any news about this ? CarouselView is a Highlight from the 4.4 version but this bug is still present and is a major one :-/

Do you have a sample please? What Forms version did you tested?

Does it still happen on 4.5.0-pre ?

thanks

I tested on 4.4 with a sample page with multiple children with static content declared in the XAML. And a button which set a value to the Position property.

I will try on 4.5.0-pre.

can you upload that sample project please?

Thanks

Forms44.zip
It was a little project for an intern tech demonstration of the new features of XF4.4.

You will have the repro in the CarouselView part.

@quentinR0bert i tested the sample and didn't see the issue. What should the steps be to reproduce?

With this sample (version 4.4 of Forms) :

  • i go to the carouselView Page
  • i swipe to the last element (the picture of "4")
  • I tap the "Set Index 1" button
  • I swipe again and the carousel go to the last image ("4") and not the next ("3").

I make a vidéo.
swipe

Hi team,
I have the same bug as described in this thread.

I have a carousel view:

         <CarouselView 
             ItemsSource="{Binding Items}"
             x:Name="carouselView"
             CurrentItemChanged="OnCurrentItemChanged" ....

And i have a button that set a specific position (in this case six) by calling a command that uses the scrollTo method:

        public async Task ExecuteScrollToCommand(){
                carouselView.ScrollTo(6);
        }

The cases:

  • if i click the button to scroll to the position six before interacting (with the swipe) with the carousel view, the element at the position six is correclty pointed and the prev element and next one are correctly rendered (after swiping again).
  • if i swipe the carousel view and then click the button to scroll to the position six, the element at the position six is correctly pointed but the next element is the next respect the element before changing at position six. The same for the previous element.

In my opinion seems that in case you use the Position or the ScrollTo method to point a new element in the carousel view, PreviousItem and CurrentItem properties are not correctly refreshed and for this if user starts to swipe again, the movements are related to the previous values of these elements.

The bug cannot allow to place buttons or other systems to change position directly because scrollTo or position are not mixing correctly with the swipe operations.

Thanks for the support.

Hi,
are there any news regarding this issue?

@rmarinho Any news about this since the additional information ?

The bug still exists also in the version 4.5.0.657 but i found a good workaround. You can avoid the problem by disabling the scroll animation by using the following property:

IsScrollAnimated="False"

After that i used the Position property to control the position of the page i want to visualize:

Position="{Binding ThePosition, Mode=TwoWay}"

Maybe you can try the same solution.
Marco.

Hi do you still see this issue on the 4.6.0 version?

It's fixed ! I have updated the sample on XF 4.6.0.800 and i doesn't reproduce the issue.
Thank you very much !

Finally! It's freaking fixed! Read all release notes, but it was never mentioned there.

Was this page helpful?
0 / 5 - 0 ratings