I have noticed that when I try to employ a DataTemplateSelector on both the ItemTemplate and the GroupHeaderTemplate (a different data template selector for each) in a ListView, that--at least in Android--this tends to cause an ArgumentOutOfRangeException. I'm not exactly sure why this happens but it is certainly unfortunate for what I'm trying to do. I have used DataTemplateSelectors before plenty of times for ItemTemplates and GroupHeaderTemplates, and they have worked fine, but this is the first time I have used them at the same time. While stepping through the code I have noticed two things:
If anyone has encountered this and has a solution or some work around it would be greatly appreciated. For the time being I'm going to try and put everything into one DataTemplateSelector that gets called for both the items and the group headers. Hopefully that will at least mitigate the faulty templates being returned.
EDIT Consolidating this into one datatemplateselector didn't work, but I guess it was worth the try.