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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Show a group header without any child views.

Thread ID:





129181 Mar 2,2017 02:12 PM UTC Mar 17,2017 06:08 AM UTC Xamarin.Forms 3
Tags: SfListView
Robbie Philips
Asked On March 2, 2017 02:12 PM UTC

Hi There,

When using grouping in a ListView is there a way to create a header for a group which has no items in the ItemsSource.  I have a button on my header for the user to create items and i need this to be visible when there are 0 items of a particular type.

I thought a hacky way to do it would be to create a default list item for each group i need displayed and have the item height set to 0.

Is there any way manually add a group so that the header can be displayed even if there are no children in the items source?

Many Thanks,

Dinesh Babu Yadav [Syncfusion]
Replied On March 3, 2017 03:36 PM UTC

Hi Robbie, 
Thank you for using Syncfusion products. 
In SfListView, we have grouped the items based on the underlying data bind to ItemsSource property and this is the actual behavior of SfListView. So in order to achieve your requirement “Displaying group headers only without items”, we have an workaround in the sample level with changing ItemsSize property at runtime. By defining the ItemsSize as “0” which you have stated and collapse all the groups using CollapseAll method while initializing the SfListView and therefore the group header items are only visible. And by customizing the GroupHeaderTemplate, you can add the items by tapping on the customized group header template and after the item is added change the ItemsSize. For your reference, we have attached the sample and you can download the same from the below link. 
In the sample, we have collapsed all the groups and customized the group header template with the header label and an image(Create.png) and defined the ItemsSize as “0”. On tapping the "Create" image, an alert will be displayed in which you can add the item as per your requirement. 
Please let us know if you require further assistance. 
Dinesh Babu Yadav 

Robbie Philips
Replied On March 16, 2017 11:08 AM UTC

Hi Dinesh,

Thanks for you response and suggestion, I have been able to get it working in my app using a similar approach to yours.

Thanks Again,

Dinesh Babu Yadav [Syncfusion]
Replied On March 17, 2017 06:08 AM UTC

Hi Robbie, 
Thanks for the update. 
Dinesh Babu Yadav 


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