We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to fit items exactly on page height on horizontal orientation

Thread ID:





142287 Jan 25,2019 02:45 AM UTC Jan 25,2019 12:10 PM UTC Xamarin.Forms 1
Tags: SfListView
Asked On January 25, 2019 02:45 AM UTC

I would like to fit sflistview exactly on the screen horizontally. so all items should be visible. I tried like below

  <sfListView:SfListView    x:Name="list" IsVisible="False" ItemsSource="{Binding Items}" SelectionMode="Single"
               SelectionBackgroundColor="Yellow"    ItemSpacing="1" AllowSwiping="False"  Orientation="Horizontal"  
                 QueryItemSize="List_QueryItemSize"    HorizontalOptions="CenterAndExpand"   VerticalOptions="FillAndExpand" >
                    <sfListView:LinearLayout />

  private void ListExercises_QueryItemSize(object sender, Syncfusion.ListView.XForms.QueryItemSizeEventArgs e)

            e.ItemSize = Height / ItemCount;
            e.Handled = true;


ItemCount is calculated based on ItemSource Count. Althought ItemSize is set correctly, listview doesnt fit exactly on screen width. Is it even possible?

Jayaleshwari N [Syncfusion]
Replied On January 25, 2019 12:10 PM UTC

Hi Emil,  
Thanks for contacting Syncfusion Support.  
We have checked the reported query from our side. We would like to know you can set ItemSize for listview based on the screen width by overriding OnSizeAllocated method and if you set any ItemSpacing, RowSpacing or Height for any element in your sample then ItemSize will be calculated by considering specified size to element.   
namespace SfListViewSample  
    public partial class MainPage : ContentPage  
        protected override void OnSizeAllocated(double width, double height)  
            base.OnSizeAllocated(width, height);  
            listView.ItemSize = width/ItemsCount;  
We have attached the working sample in which listview fits with the screen width as per requirement and you can download the same from the following location. 
Screenshot : 
Please let us know if you would require any further assistance.  
Jayaleshwari N 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon