Created
July 19, 2018 14:31
-
-
Save jfversluis/6e7acf80d4bcf43af9fcc1c67c46dca2 to your computer and use it in GitHub Desktop.
The DataTemplateSelector
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 AlternateColorDataTemplateSelector : DataTemplateSelector | |
{ | |
public DataTemplate EvenTemplate { get; set; } | |
public DataTemplate UnevenTemplate { get; set; } | |
protected override DataTemplate OnSelectTemplate(object item, BindableObject container) | |
{ | |
// TODO: Maybe some more error handling here | |
return ((List<string>)((ListView)container).ItemsSource).IndexOf(item as string) % 2 == 0 ? EvenTemplate : UnevenTemplate; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment