Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syncfusionexamples/level-based-formatting-of-group-header-listview-xamarin
This example demonstrate how to apply background color for different group in xamarin.forms listview
https://github.com/syncfusionexamples/level-based-formatting-of-group-header-listview-xamarin
color grouping xamarin xamarin-forms xamarin-listview
Last synced: about 2 months ago
JSON representation
This example demonstrate how to apply background color for different group in xamarin.forms listview
- Host: GitHub
- URL: https://github.com/syncfusionexamples/level-based-formatting-of-group-header-listview-xamarin
- Owner: SyncfusionExamples
- Created: 2018-11-29T10:41:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-28T13:18:37.000Z (8 months ago)
- Last Synced: 2024-05-29T02:13:35.270Z (8 months ago)
- Topics: color, grouping, xamarin, xamarin-forms, xamarin-listview
- Language: C#
- Size: 1.85 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to format the group header for different levels of grouping in Xamarin.Forms ListView(SfListView)?
You can format the different levels of the group by binding the [converter](https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/converters) for the loaded elements to the [GroupHeaderTemplate](https://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfListView.XForms~Syncfusion.ListView.XForms.SfListView~GroupHeaderTemplate.html) of the Xamarin.Forms [SfListView](https://help.syncfusion.com/xamarin/listview/overview).
You can also refer the following article.
https://www.syncfusion.com/kb/11685/how-to-format-the-group-header-for-different-levels-of-grouping-in-xamarin-forms
**XAML**
Defined group header template with **converter**.
``` xml
```
**C#**Set [BackgroundColor](https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.visualelement.backgroundcolor?view=xamarin-forms) and [Padding](https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.layout.padding) to the different group levels.
``` 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.Aqua;
else
return Color.AntiqueWhite;
}
else
{
if ((int)value == 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)
{
return value;
}
}
```
**Output**![MultiGrouping](https://github.com/SyncfusionExamples/level-based-formatting-of-group-header-listview-xamarin/blob/master/ScreenShot/MultiGrouping.png)