Formating grouping

Hey Guys,

Probably a simple one.  I have a couple of levels of grouping and want a different format for each,  any ideas on how to do this?

                teamfixture.DataSource.GroupDescriptors.Add(new GroupDescriptor()
                    {
                        PropertyName = "TeamType"
                    });
                    teamfixture.DataSource.GroupDescriptors.Add(new GroupDescriptor()
                    {
                        PropertyName = "TeamAName"
                    });


So I would want "TeamType"  to say have a black background and white text,   and  "TeamAName" to have white background and black text.

regards

B

1 Reply

RS Rawoof Sharief Muthuja Sherif Syncfusion Team April 26, 2018 12:19 PM UTC

Hi Ben, 
 
Thanks for contacting Syncfusion support. 
 
We have checked the reported query “Change the background color for different level of group” from our side with our sample. In our sample we have a loaded the SfListView with multi-level grouping and change the background color for the group header using the converter as like below code snippet. 
 
Code Example[XAML]: 
<syncfusion:SfListView x:Name="listView" ItemSize="80"   
                       AllowGroupExpandCollapse="True" SelectionMode="None" 
                       GroupHeaderSize="40" 
                       ItemsSource="{Binding EmployeeInfo}" ItemSpacing="2" > 
 
    <syncfusion:SfListView.DataSource> 
       <dataSource:DataSource> 
         <dataSource:DataSource.GroupDescriptors> 
             <dataSource:GroupDescriptor PropertyName="Designation" /> 
             <dataSource:GroupDescriptor PropertyName="Level" /> 
         </dataSource:DataSource.GroupDescriptors> 
       </dataSource:DataSource> 
    </syncfusion:SfListView.DataSource> 
 
    <syncfusion:SfListView.GroupHeaderTemplate> 
       <DataTemplate> 
         <ViewCell> 
           <ViewCell.View> 
             <StackLayout BackgroundColor="{Binding Level,Converter={StaticResource TemplateConverter}}" Padding="{Binding Level,Converter={StaticResource TemplateConverter}}"> 
             <Label Text="{Binding Key}" FontSize="20" FontAttributes="Bold" Margin="3" 
                    VerticalOptions="Center" HorizontalOptions="Start"/> 
              </StackLayout> 
            </ViewCell.View> 
          </ViewCell> 
       </DataTemplate> 
    </syncfusion:SfListView.GroupHeaderTemplate> 
</syncfusion:SfListView> 
 
CodeExample[C#]: 
public class GroupHeaderConverter : IValueConverter 
{ 
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
       if (targetType.Name == "Color") 
          { 
              if ((int)value == 1) 
                  return Color.FromHex("#db3232"); 
              else 
                  return Color.FromHex("#32dbd0"); 
          } 
       else 
          { 
              if ((int)value == 1) 
                  return new Thickness(5, 5, 5, 0); 
              else 
                  return new Thickness((int)value * 15, 5, 5, 0); 
          } 
    } 
} 
 
 
For your reference, we have attached the sample and you can download it from below link. 
 
 
Please let us know if you require further assistance. 
 
Regards, 
Rawoof M. 


Loader.
Up arrow icon