- Home
- Forum
- Xamarin.Forms
- SfListView displays empty space under the last item
SfListView displays empty space under the last item
Hello,
On the previous version of SfListView, unless I declared fixed size of the listview it autosized depending on the size of element displayed. However, after I updated to the newest version (16.3.0.29), by default it displays all items and a huge blank space underneath them. Is there a way to correctly autosize listview?
Faithfully,
Weronika Ziarkowska
SIGN IN To post a reply.
3 Replies
JN
Jayaleshwari N
Syncfusion Team
November 16, 2018 07:12 AM UTC
Hi Weronika,
Thanks for Contacting Syncfusion Support.
We have checked the reported query “SfListView displays empty space under the last item” from our side. We would like to know that we have modified the behavior of SfListView when loaded inside layouts such as Grid, StackLayout and ScrollView. In these layouts, the SfListView works similar to Xamarin.Forms ListView. We have already mentioned regarding this in our release notes and you can refer the same from the below link.
Behavior Change: https://help.syncfusion.com/xamarin/release-notes/v16.2.0.50?type=all#sflistview-breaking-changes
We would like to inform that the SfListView measures and allocates size only when its parent element calls for Measure to calculate the size of the child element(i.e., In this case SfListView) to render in the View. When RowDefinition is ‘*’, SfListView OnMeasure won’t be called from its parent element Grid. Same thing applies for StackLayout when loaded in Grid ‘*’ RowDefinition. So even when we define HeightRequest for SfListView, it will be ignored.
So if you want to load the SfListView in exact height as its extent, load it inside Grid ‘Auto’ RowDefinition and set its TotalExtent to its HeightRequest as below.
We have updated this in UG documentation also. You can refer from the following location.
We have attached the tested sample for your reference and you can download the same from the following location.
Please let us know if you would require further assistance.
Regards,
Jayaleshwari N.
WZ
Weronika Ziarkowska
November 19, 2018 11:10 AM UTC
Hello,
Thank you for your answear, the provided sample helped me solve my issue. Is there a way to declare behaviors for SfListView in c# and not in xaml?
Regards,
Weronika Ziarkowska
JN
Jayaleshwari N
Syncfusion Team
November 20, 2018 05:18 AM UTC
Hi Weronika,
Thanks for the update.
We have checked the query regarding “Declare behaviors for SfListView in C#” from our side. You can achieve your requirement by adding the defined listview behavior in ListView.Behaviors collection.
|
public MainPage()
{
InitializeComponent();
listView.Behaviors.Add(new ListViewBehavior());
} |
We have attached the modified sample for your reference and you can download the same from the following location.
Sample link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/140956Behavior-515480952
Please let us know if this solution meets your requirement.
Regards,
Jayaleshwari N.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
WZ Weronika Ziarkowska
- Nov 15, 2018 05:27 PM UTC
- Nov 20, 2018 05:18 AM UTC