Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
**[View document in Syncfusion Xamarin Knowledge base](https://www.syncfusion.com/kb/12095/how-to-update-empty-group-header-text-in-xamarin-forms-listview-sflistview)**

## Sample

```xaml
<syncfusion:SfListView x:Name="listView" ItemSize="60" ItemsSource="{Binding ContactsInfo}">
<syncfusion:SfListView.ItemTemplate >
<DataTemplate>
<code>
. . .
. . .
<code>
</DataTemplate>
</syncfusion:SfListView.ItemTemplate>
<syncfusion:SfListView.GroupHeaderTemplate>
<DataTemplate>
<code>
. . .
. . .
<code>
</DataTemplate>
</syncfusion:SfListView.GroupHeaderTemplate>
</syncfusion:SfListView>

C#:
ListView.DataSource.GroupDescriptors.Add(new GroupDescriptor()
{
PropertyName = "Group",
KeySelector = (object obj1) =>
{
var item = (obj1 as Contacts);
return item.Group;
},
});
ListView.QueryItemSize += ListView_QueryItemSize;

private void ListView_QueryItemSize(object sender, QueryItemSizeEventArgs e)
{
if (e.ItemType == ItemType.Record && (e.ItemData as Contacts).ContactName == "")
{
e.ItemSize = 0;
e.Handled = true;
}
}

Converter:
public class GroupHeaderConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return null;

var groupResult = value as GroupResult;
if (groupResult.Key.ToString() == "WORK")
return groupResult.Count > 1 ? "WORK" : "EMPTY WORK";
else
return groupResult.Count > 1 ? "PERSONAL" : "EMPTY PERSONAL";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
```