Forum Xamarin Xamarin.Forms

ListView with Image in ItemTemplate slightly laggy

JohanDTJohanDT USMember ✭✭
edited March 2015 in Xamarin.Forms

So I am loading about 200 items into my ListView, using the following item template

            <StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal">
              <Image WidthRequest="21" HeightRequest="25" Source="{Binding NoteTypeImage}" />
              <StackLayout Padding="5,0,0,0" VerticalOptions="StartAndExpand" Orientation="Vertical">
                <Label Text="{Binding NotedByFullName}" YAlign="Center" Font="Medium" />
                <Label Text="{Binding NotedOn}" YAlign="Center" Font="Micro" />

My question is, is it laggy because it needs to fetch the image from the url for every single item (no caching involved)?
There are 3 different images that display, depending on a condition.

Would it be possible, to define the 3 images as static resources and then bind to the right one somehow?
If this is possible, will it fix the laggy issue?


  • VitorLeitaoVitorLeitao USMember
    edited March 2015

    Hi @ That can be the case, and you can probably set the static images in the Binding or use a converter for it.

    From what i see of your xaml, your layout is very similar to a ImageCell (image, and two texts). Why not use this instead?

    Another tip, and this one is a bit of work, if performance in the list is a priority, you should probably implement the list in Xamarin.IOS and Xamarin.Android, since XF takes quite a bit overhead with the lists (in android for example you can create the list has native ListView and the cell in axml and inflate it, this would give you a huge performance boost on android at least).

    Another advice for this, if you really really need to have the images from a URL, make them load async, or you might have a lot of memory issues for loading a lot of images

  • JohanDTJohanDT USMember ✭✭

    This is just a simple version of my Item (for clarity).

    I am not really keen on doing platform specific code as I am attempting to do 90%+ code share.
    I will attempt the static resources and report back.

Sign In or Register to comment.