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

how to fit items exactly on page height on horizontal orientation

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?

1 Reply

JN Jayaleshwari N Syncfusion Team January 25, 2019 07:10 AM

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 

Live Chat Icon For mobile
Up arrow icon