Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

CollectionView: detect there's no scroll / has scroll / scroll bottom

SergTomcatSergTomcat Member ✭✭

I have to find current "scroll" state whether there's no scroll, or scroll active and in a certain position, affecting visibility and behavious of other controls. There three cases:

  1. All loaded items are fitted inside CollectionView area and there is no scroll needed.

  1. Items took more space than available and vertical scroll appeared

  1. Scroll hit the bottom

Last two can be achieved via RemainingItemsThreshold property and events, but they don't work in UWP.

And I cannot figure out how to detect if there's any scroll at all.


  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Yes, this RemainingItemsThreshold not work in UWP. This issue is reported in the github.

    Here is a workaround. Here is running GIF.

    You can use Scrolled event to achieve it

     <CollectionView x:Name="MyCollection" HeightRequest="150"  Scrolled="MyCollection_Scrolled"  BackgroundColor="Green">

    Background code.

      private void MyCollection_Scrolled(object sender, ItemsViewScrolledEventArgs e)
                if (Device.RuntimePlatform != Device.UWP)
                if (sender is CollectionView cv)
                    int lastindex = e.LastVisibleItemIndex+1;
                    mylabel1.Text = "Current LastVisibleItem  " + lastindex.ToString();
                    if (str.Length > lastindex)
                        // have scrollbar
                    if ((lastindex)== str.Length)
                        mylabel2.Text = "Scroll to the end";
  • SergTomcatSergTomcat Member ✭✭

    @LeonLu, thank you for the workaround.

    However, Scrolled event doesn't fire if elements all fit initially and no scroll present. And if I start add new items to ObservableCollection, Scrolled event also doesn't fire, although new items already reached bottom and vertical scroll appeared. Sadly, Scrolled triggers only with user interaction or ScrollTo method.

    str in your example is ItemSource?

  • LeonLuLeonLu Member, Xamarin Team Xamurai
    edited July 21

    str in your example is ItemSource?

    Yes it is .

    str = new string[]
        "Capuchin Monkey",
        "Blue Monkey",
        "Squirrel Monkey",
        "Golden Lion Tamarin",
        "Howler Monkey",
        "Japanese Macaque"
                mylabel.Text = "counts in string[] " + str.Length.ToString();
                MyCollection.ItemsSource = str;
Sign In or Register to comment.