diff --git a/README.md b/README.md index fc5eda9..8b50d1d 100644 --- a/README.md +++ b/README.md @@ -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 + + + + + . . . + . . . + + + + + + + . . . + . . . + + + + + +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(); + } +} +```