Skip to content

Instantly share code, notes, and snippets.

@grimorde
Created February 20, 2020 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grimorde/e1a06d7474bc16059c6cb1bce9efdb1f to your computer and use it in GitHub Desktop.
Save grimorde/e1a06d7474bc16059c6cb1bce9efdb1f to your computer and use it in GitHub Desktop.
Alternate Row Colour Converter
public class AlternateRowColourConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || parameter == null) return Color.LightGray;
var index = ((ListView)parameter).ItemsSource.Cast<object>().ToList().IndexOf(value);
if (index % 2 == 0)
{
return "#eaecef";
}
else
{
return "#d7d9dd";
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment