xamarin/Xamarin.Forms

ListView's GroupHeaderTemplate do not work with DataTemplateSelector on Android

Open

#3,407 opened on Jul 26, 2018

 (14 comments) (2 reactions) (0 assignees)C# (1,926 forks)batch import
a/listviewe/9 :clock9:help wantedi/highin-progressinactivep/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

version Xamarin.Forms.3.1.0.637273 and Xamarin.Forms 3.1.0.583944

I want to use the DataTemplateSelector for the GroupHeaderTemplate.

<ListView Grid.Row="1" ItemsSource="{Binding PickerGroups}" IsGroupingEnabled="True" ItemTemplate="{StaticResource PickerDataTemplateSelector}"
                  GroupHeaderTemplate="{StaticResource PickerDataTemplateSelector}"  CachingStrategy="RecycleElementAndDataTemplate">
</ListView>

I get here such a crash:

ListProxy.get_Item (System.Int32 index)
D:\a\1\s\Xamarin.Forms.Core\ListProxy.cs - line 127
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index

1 ListProxy.get_Item (System.Int32 index) D:\a\1\s\Xamarin.Forms.Core\ListProxy.cs:127
2 IList.get_Item (System.Int32 index) D:\a\1\s\Xamarin.Forms.Core\ListProxy.cs:444
3 ListViewAdapter.GetItemViewType (System.Int32 position) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:172
4 BaseAdapter.n_GetItemViewType_I (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position)
5 (wrapper dynamic-method) System.Object.cbacde75-f4e8-4fe2-bec7-81edead3c9fe(intptr,intptr,int)

Contributor guide