Search code examples
xamarinxamarin.formsxamarin.androidxamarin.ioscollectionview

Xamarin CollectionView Current Group


How to get current visible group name in CollectionView when scrolling? I want to show this info in page title.

myCollectionView.Scrolled += (object sender, ItemsViewScrolledEventArgs e) =>
{
    int first_index = e.FirstVisibleItemIndex;
};

Solution

  • You could get the index and then get the matched item to get the group name.

       int first_index = e.FirstVisibleItemIndex;
            if (first_index!=0)
            {
                Name = ObservCollectionCategory[first_index-1].Category_Name;
                //The ObservCollectionCategory is the item source of Collectionview.
            }
    

    And then binding the name of the title.

    Title="{Binding Name}"