Listview size is not properly fit due to dynamic row- and static span count

Hi, I've initially used SfListView to list my categories (financial types) with dynamic count in a span layout. 3 columns fixed and rows are dependent to count of items (from 4 up to 14 as of now). 

However, as you can notice from the screenshots, the layout of screen is terrible. 
I want yellow SfListview to fit in the layout regarding to rows...

I cannot find the hint and looking forward to your precious support. 

PS: I've got online chat support but abstracts from documentation and KB relavant to listview limitations did not help me or was not clear to solve the issue.

               
                    Grid.Row="1"
                    Padding="8"
                    AutoFitMode="Height"
                    BackgroundColor="LightYellow"
                    ItemSpacing="4"
                    ItemsSource="{Binding FinancialPlanTypes}"
                    SelectionBackgroundColor="Transparent">
                   
                       
                           
                                Padding="0"
                                BackgroundColor="White"
                                BorderColor="LightGray"
                                CornerRadius="6"
                                HasShadow="true">
                               
                                   
                                       
                                       
                                   
                                   
                                        Grid.Row="1"
                                        HeightRequest="64"
                                        Source="{Binding ID, Converter={StaticResource planIconConverter}}"
                                        WidthRequest="64" />
                                   
                                        Grid.Row="2"
                                        HorizontalTextAlignment="Center"
                                        Style="{StaticResource MediumBoldLabelStyle}"
                                        Text="{Binding Name}" />
                               
                           
                       
                   
                   
                       
                   
               



Attachment: SfListviewLayout_3d2bdeef.zip

1 Reply

SS SaiGanesh Sakthivel Syncfusion Team May 11, 2020 11:43 AM UTC

Hi Murat, 
 
Thank you for contacting Syncfusion support. 
 
We have checked the reported query “ListView size is not properly fit” from our end. We would like to inform that you can achieved your requirement by calculating the total height of listview Container by using container propertychanged and set the calculated totalextent value to the Listview HeightRequest. Please refer to the following code snippet for your reference. 
 
Code Snippet 
public MainPage() 
{ 
    InitializeComponent(); 
    container = listView.GetVisualContainer(); 
    container.PropertyChanged += Container_PropertyChanged;     
} 
private void Container_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) 
{ 
    Device.BeginInvokeOnMainThread(async () => 
    { 
        var totalextent = (double)container.GetType().GetRuntimeProperties().FirstOrDefault(container => container.Name == "TotalExtent").GetValue(container); 
        listView.HeightRequest = totalextent; 
    }); 
} 
 
Please refer to the following UG link. 
 
We hope this helps. Please let us know if you need any further assistance. 
 
Regards, 
SaiGanesh Sakthivel

Loader.
Up arrow icon