0

I'm making an app that loads some images to a scrollview and I need to detect when the user reaches the bottom of the scrollview to load more images.

I've already tried "scrollView.ContentSize.Height" but ContentSize doesn't exist.

What can I do? I'm not using Xamarin.Forms, but can I use it with Xamarin.Android?

  • Possible duplicate of [Detect end of ScrollView](https://stackoverflow.com/questions/10316743/detect-end-of-scrollview) – FreakyAli Aug 19 '19 at 14:40
  • Possible duplicate of [Detect when Xamarin Scrollview has reached the end](https://stackoverflow.com/questions/51369639/detect-when-xamarin-scrollview-has-reached-the-end) – Bruno Caceiro Aug 19 '19 at 15:23

2 Answers2

0

you can try something like this:

private void ScrollView_OnScrolled(object sender, ScrolledEventArgs e)
 {
            if (!(sender is ScrollView scrollView))
                return;

            var scrollingSpace = scrollView.ContentSize.Height - scrollView.Height;

            if (scrollingSpace > e.ScrollY)
                return;

            // load more content.
            DisplayAlert("Alert", "End of scroll view detected", "OK");
        }
Nehl-IT
  • 301
  • 1
  • 11
0

You can try this as mentioned by https://stackoverflow.com/users/1691980/bruno-caceiro:

private void OnScrolled(object sender, ScrolledEventArgs e)
    {
        MyScrollView scrollView = sender as MyScrollView;
        double scrollingSpace = scrollView.ContentSize.Height - scrollView.Height;

        if (scrollingSpace <= e.ScrollY) // Touched bottom
            // Do the things you want to do
    }