2
votes

I have a ListView with images that work as a menu in my Xamarin.Forms App. Here's the view:

enter image description here

The last item is just a little bit out of the screen, so the ListView needs to scroll down in order to reach the end of the menu. The first time the view is presented it reaches the end without issues. Then when I navigate and then return to this view I can't reach the end no more.

You can find the live example here:

https://media.giphy.com/media/vvWQATVNlQ5ztX7New/giphy.gif

Here's my XAML code:

<StackLayout>

    <ListView 
        x:Name="sampleListView"
        ItemsSource="{Binding MyList}"
        SeparatorVisibility="None"
        SeparatorColor="Transparent"
        ItemSelected="OnItemSelected"
        HasUnevenRows="true">

        <ListView.Margin>
            <OnPlatform x:TypeArguments="Thickness"
                  iOS="0,2,0,0"
                  Android="0,0,0,2" 
            />
        </ListView.Margin>

        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>                                  

                    <Grid BackgroundColor="#EFEFEF">

                        <ffimageloading:CachedImage                         
                            FadeAnimationEnabled="true" 
                            Source="{ Binding ImageNavigation }"
                            VerticalOptions="StartAndExpand"
                            Aspect="AspectFill"
                            HeightRequest="{Binding RowSizeMainMenu}"
                        />

                    </Grid>

                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>

    </ListView>

</StackLayout>

Any help will be appreciated.

Note: this is working OK in Android, the issue is visible only in iOS.

2
Why don't u use a Grid? - GregorMohorko
Try to user grid instead of stacklayout - Gaurang Dave
If you remove the stacklayout around the listview, does it work? - sme
i think this still a bug in xamarin try using CachingStrategy="RecycleElement" - Abdullah Tahan
@AbdullahTahan, that did the trick. I can accept your question as correct, just write it down. Thanks! - Luis de Haro

2 Answers

2
votes

I think this still a bug in xamarin try using CachingStrategy="RecycleElement"

1
votes

Set below property of your main StackLayout

VerticalOptions="FillAndExpand"