Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The DataTemplateSelector
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