Articles in this section
Category / Section

How to share items source among Xamarin.Forms ListView?

5 mins read

You can programmatically split the collections of items among Xamarin.Forms ListView loaded in CarouselPage.


Define CarouselPage and load the ListViewPage to CarouselPage.ItemTemplate.

<CarouselPage xmlns=""


SfListView is defined in the ListViewPage with the binding value of (.)

<ContentPage xmlns=""
            <syncfusion:SfListView x:Name="listView" ItemSize="100" ItemsSource="{Binding .}">
                    <syncfusion:GridLayout SpanCount="3"/>
                <syncfusion:SfListView.ItemTemplate >
                        <Grid x:Name="grid">
                                <ColumnDefinition Width="0.3*" />
                                <ColumnDefinition Width="0.7*" />
                            <Image Source="{Binding ContactImage}" VerticalOptions="Center" HorizontalOptions="Center" HeightRequest="50" WidthRequest="50"/>
                            <Grid Grid.Column="1" RowSpacing="1" Padding="10,0,0,0" VerticalOptions="Center">
                                <Label LineBreakMode="NoWrap" TextColor="#474747" Text="{Binding ContactName}"/>
                                <Label Grid.Row="1" Grid.Column="0" TextColor="#474747" LineBreakMode="NoWrap" Text="{Binding ContactNumber}"/>


In the OnSizeAllocated override, send page height to the ViewModel class to determine the items count to split the ItemsSource for the CarouselPage.

public partial class ListViewCarousel : CarouselPage
    PagesViewModel pagesViewModel;
    public ListViewCarousel()
    protected override void OnSizeAllocated(double width, double height)
        if (height > 0 && BindingContext == null)
            pagesViewModel = new PagesViewModel(height);
            BindingContext = pagesViewModel;
            ItemsSource = pagesViewModel.CarouselPages;
        base.OnSizeAllocated(width, height);


In carousel PagesViewModel, ItemsPerPage count is determined by ItemSize and SpanCount which determines the number of pages based on the Items count. PagesViewModel defines the collection for each page and adds it to the collection that is bound to the SfListView.ItemsSource.

public class PagesViewModel
    public ObservableCollection<List<Contacts>> CarouselPages { get; set; }
    public PagesViewModel(double height)
        int j = 0;
        int itemsPerPage = (int)(height / 100) * 3;
        int temp = itemsPerPage;
        CarouselPages = new ObservableCollection<List<Contacts>>();
        var contactsviewmodel = new ContactsViewModel();
        var pageCount = Math.Ceiling((double)contactsviewmodel.ContactsInfo.Count / itemsPerPage);
        for (int i = 0; i < pageCount; i++)
            var source = contactsviewmodel.ContactsInfo.Skip(j).Take(temp);
            var items = source.AsEnumerable().ToList();
            j += itemsPerPage;


Demo image to split the ItemsSource for SfListView with CarouselPage.

View sample in GitHub


I hope you enjoyed learning about how to share items source among Xamarin.Forms ListView with carousel page.

You can refer to our Xamarin.Forms ListView feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied