Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect scrolling ended in Xamarin.Forms.Scrollview

I am trying to customize a scroll view to meet my particular set of requirements, and what I would like to do it detect when the user stops scrolling or otherwise takes their finger off the screen. I have tried several methods of attaching event listeners but have yet to find one that will actually fire any events.

I need to make this work on android and iOS, and would be happy to do this in either cross platform or platform specific code.

If anyone can provide any guidance, I would be extremely grateful!

As a small side note, if anyone could explain why in my custom scrollview renderer doing Touch += MyTouchHandler doesn't allow my touch handler to be called, that would be enormously helpful.

like image 291
Syynth Avatar asked Sep 14 '25 04:09

Syynth


1 Answers

You can detect it by implementing this event handler: Assuming your list is called Items, then you need to add this code to your page.xaml.cs file:

    var listview = new ListView ();

    listview.ItemsSource = Items;
    listview.ItemAppearing += (sender, e) =>
    {
       if(isLoading || Items.Count == 0)
           return;

       //hit bottom!
       if(e.Item.ToString() == Items[Items.Count - 1])
       {
           LoadItems();
       } 
   }

You can check the full implementation details here: https://gist.github.com/jamesmontemagno/465ced24fc8a206dcaf3#file-loadmoreonbottom-cs

like image 72
IdoT Avatar answered Sep 17 '25 20:09

IdoT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!