ListView fast scrolling causes contents to change position

JxamarinJxamarin GBMember ✭✭
edited February 15 in Xamarin.Forms

Hello,

I have an issue with my current implementation of the ListView. The Listview is binded to a collection inside my viewmodel, and if I scroll quickly on the listview, the positions of some of the labels inside the listview cells swap position. Sometimes these labels also have half the text cut off. This issue only occurs if I scroll quickly.

I have already tried changing the CachingStrategy to Retain, but that made no difference.

This is the XAML I'm using:

            <ListView ItemsSource="{Binding ItemList, Mode=OneWay}"
                      ItemTapped="SelectBrand"
                      HasUnevenRows = "true"
                      SelectionMode="None"
                      IsRefreshing="{Binding IsBusy, Mode=OneWay}">

                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Grid>
                                <StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" Padding="20,10,20,10">
                                    <Image AutomationId="ImageId" Source="{Binding LogoStream}" HorizontalOptions="Start" WidthRequest="50" HeightRequest="50" />
                                    <StackLayout Padding="20,0,0,0" VerticalOptions="Center">
                                        <Label VerticalOptions="Center" Text="{Binding Name}" />
                                    </StackLayout>
                                </StackLayout>
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

Thanks, help would be much appreciated.

Answers

  • StandaMikesStandaMikes USMember ✭✭

    Try to add CachingStrategy="RecycleElement" in your listview.

    How many items do you have in the collection? If it's large amount of data, you should think about paging (continuous loading).

  • JxamarinJxamarin GBMember ✭✭
    edited February 15

    @StandaMikes said:
    Try to add CachingStrategy="RecycleElement" in your listview.

    How many items do you have in the collection? If it's large amount of data, you should think about paging (continuous loading).

    Thanks for responding.

    I tried that and it did solve the issue of the contents moving position, but unfortunately the list is now extremely slow to load in (I should've also mentioned that I am loading a small thumbnail image for each cell row).

    Right now I have about 70 items in the list.

Sign In or Register to comment.