<syncfusion:SfListView>
<syncfusion:SfListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout BackgroundColor="{Binding .,Converter={StaticResourceTemplateConverter}}"
Padding="{Binding Level,Converter={StaticResource TemplateConverter}}">
<Label Text="{Binding Key}" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</syncfusion:SfListView.GroupHeaderTemplate>
</syncfusion:SfListView>
|
public class GroupHeaderConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return value;
var groupResult = value as GroupResult;
if (groupResult == null)
return value;
if (targetType.Name == "Color")
{
if ((int)groupResult.Level == 1 && (int)groupResult.Count > 1)
return Color.FromHex("#D3D3D3");
else
return Color.AliceBlue;
}
else
{
if ((int)groupResult.Level == 1)
return new Thickness(5, 5, 5, 0);
else
return new Thickness((int)value * 15, 5, 5, 0);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |