Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
**[View document in Syncfusion .NET MAUI Knowledge Base](https://www.syncfusion.com/kb/13165/how-to-apply-alternate-row-style-in-net-maui-listview-sflistview)**

## Sample

```xaml
<ContentPage.Resources>
<ResourceDictionary>
<local:IndexToColorConverter x:Key="IndexToColorConverter"/>
</ResourceDictionary>
</ContentPage.Resources>

<listView:SfListView x:Name="listView" ItemSize="50" ItemsSource="{Binding ContactsInfo}" >
<listView:SfListView.ItemTemplate>
<DataTemplate>
<code>
. . .
. . .
<code>
</DataTemplate>
</listView:SfListView.ItemTemplate>
</listView:SfListView>


C#:

public class IndexToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var listview = parameter as SfListView;
var index = listview.DataSource.DisplayItems.IndexOf(value);

return index % 2 == 0 ? Colors.LightGray : Colors.Aquamarine;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
```