Forum Cross Platform with Xamarin

ListView With IsGroupingEnabled="true"

I have a list view when trying to scroll the list I get.
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
at at (wrapper dynamic-method) System.Object.24202da5-a4bc-4735-b8b8-424675ae1634(intptr,intptr,int)
at at (wrapper native-to-managed) System.Object.24202da5-a4bc-4735-b8b8-424675ae1634(intptr,intptr,int)

If I take out my grouping it works fine. I am only seeing this on Android on IOS it works fine.
XF version I have is

Also I noticed that in Android only
When I tap on cell or try and scroll for some reason the action goes to my Template selector. For IOS the template selector class is called on start up and that is it.


Best Answer

  • MuhiMuhi ✭✭
    Accepted Answer

    I solved my Problem thanks .....


  • David_HollowellDavid_Hollowell USXamarin Team Xamurai
    edited July 2018

    I can't say for sure, without seeing a sample, what might cause this. Do you have some basic steps to setup a repro with code, or a sample project (minimal, with no 3rd party)?
    IsGroupingEnabled modifies how the items in the list are indexed, so each group has an index, and group has it's own index range, rather than a flat index for the entire collection.

    We have a sample here, that might help you to understand and fix the problem.
    Otherwise, can you let me know how to reproduce this? (perhaps with code or minimized solution sample?)

  • MuhiMuhi Member ✭✭

    Yes I should have put some code sorry..

    Ok so in my VM I have my

    public ObservableCollection<ViewListGrouping<GroupViewHeader, NewsFeed>> GroupedItems
    And this gets newed up and populated.

    My ViewListGrouping is a
    _public class ViewListGrouping<K, T> : ObservableCollection
    public K Key { get; private set; }

        public ViewListGrouping(K key, List<T> items)
            Key = key;
            foreach (var item in items)

    In my XAML

    I have templates for each of the Headers and for each of the NewsFeed types.

    I have a class to back the template selection.
    public class NewsFeedTemplateSelector : DataTemplateSelector

    And the last think in XAML is the view list

    ListView x:Name="datafeed"
    ItemsSource="{Binding GroupedItems}"
    ItemTemplate="{StaticResource newsFeedTemplateSelector}"
    IsRefreshing="{Binding IsBusy, Mode=OneWay}"
    RefreshCommand="{Binding RefreshCommand}"
    GroupDisplayBinding = "{Binding Key}"
    GroupHeaderTemplate="{StaticResource newsFeedHeaderTemplateSelector}">

    On the code behind I really don't do much

    I bind to the VM and call its init to hydrate the view object GroupedItems
    And the rest is just for the ItemTapped and pull to refresh.

    So in the end I don't think I'm doing anything that big or complex.

    I have types of news feeds
    All the type A's I want to group under header A
    All the type B's I have grouped under header B .. header B is the day of the week for this Month

    Thanks for any help you can give me.. If you need more info I can try and get it to you..

  • MuhiMuhi Member ✭✭
    Accepted Answer

    I solved my Problem thanks .....

Sign In or Register to comment.