Created
February 20, 2020 12:28
-
-
Save grimorde/e1a06d7474bc16059c6cb1bce9efdb1f to your computer and use it in GitHub Desktop.
Alternate Row Colour Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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