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.
Unfortunately, activation email could not send to your email. Please try again.

Customizing Group Header TItles

Thread ID:

Created:

Updated:

Platform:

Replies:

131621 Jul 19,2017 10:46 PM Jul 21,2017 12:36 AM Xamarin.Forms 3
loading
Tags: SfListView
pumaprog
Asked On July 19, 2017 10:46 PM

Hello - I am using a group descriptor to group items on an sfListView.  The Property that is being used is called "Checked", which brings in a 1 or 0 value.  So, with the group headers, the two groups are called 1 and 0.  I'd like to call them 'Failed' and 'Passed', respectively.  Is there a way to convert the property in the group headers to another value?

            listView.DataSource.GroupDescriptors.Add(new GroupDescriptor()
            {
                PropertyName = "Checked",
                KeySelector = (object obj1) =>
                {
                    var item = (obj1 as HistoryItem);
                    return item.Checked.ToString();
                }
            });

Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On July 20, 2017 07:49 AM

Hi Tommy, 
 
We have checked your query “Need to customize GroupHeader title” from our side. You can customize the GroupHeader title based on the value obtained from the ‘Checked’ property by using Converter. 
In the Converter, you need to check whether the value obtained is ‘1’ or ‘0’ and convert into required string value[‘Passed’ or ‘Failed’]. Please refer the below code example to know how to change the GroupHeader Key value using IntToStringConverter. 
 
Code example:[C#] 
public class IntToStringConverter : IValueConverter 
{ 
  public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
  { 
    if (value.ToString() == "1") 
      return "Passed"; 
    return "Failed"; 
  } 
 
  public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
  { 
    throw new NotImplementedException(); 
  } 
} 
 
Code example:[XAML] 
<DataTemplate x:Name="GroupHeaderTemplate"  x:Key="GroupHeaderTemplate"> 
  <ViewCell> 
    <ViewCell.View> 
      <Grid BackgroundColor="#E4E4E4"> 
        <Grid.ColumnDefinitions> 
          <ColumnDefinition Width="*" /> 
        </Grid.ColumnDefinitions> 
          <Label Text="{Binding Key,Converter={StaticResource IntToStringConverter}}" 
                 FontSize="22" 
                 FontAttributes="Bold" 
                 VerticalOptions="Center" 
                 HorizontalOptions="Start" 
                 Margin="20,0,0,0" /> 
      </Grid> 
    </ViewCell.View> 
  </ViewCell> 
</DataTemplate> 
 
For your reference we have attached the working sample link below, 
 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 


pumaprog
Replied On July 20, 2017 09:38 AM

Thanks for the response, Muthu!  This solution worked perfectly!

Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On July 21, 2017 12:36 AM

Hi Tommy, 
 
Thanks for the update. 
 
G.Muthu Kumaran. 


CONFIRMATION

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.

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.

;