Implement a Infinity Scroll with pull to refresh

lfernandolfernando Member ✭✭
edited October 2018 in Xamarin.Forms

Hey guys!

I have a list with infinity scrool working, but when i try to use pull to refresh in my list my content is not refresh my data (in list).
Should i use Observable Collection instead Infinity Scroll Collection? (But, if a made the change, my list is not working with exact same behavior.)

Can i implement the two ways?

Thanks for the future responses.

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Have you checked this library :https://github.com/mattleibow/InfiniteScrolling ?

  • lfernandolfernando Member ✭✭
    edited October 2018

    Yes @ColeX, i'm using this. I have a list "working". But the not pull to refresh. I'll pass the code.

    My Constructor

            Item = new InfiniteScrollCollection<Group<string, Model>>()
            {
                OnLoadMore = async () =>
                {
    
                    Model mdel = new Model();
    
                    foreach (var item in Item)
                    {
                        var itemProp = item[item.Count - 1].Prop;
                        mdel.Prop = itemProp;
                    }
    
                    var items = await CallWebServiceAsync(mdel.Prop, mdel.Prop2);
                    return items;
                },
    
                OnCanLoadMore = () =>
                {
                    return true;
                },
            };
    

    Method Pull to Refresh

    IsRefreshing = true;
    await CallWebService();
    IsRefreshing = false;
    

    My Prop

    private InfiniteScrollCollection<Group<string, Model>>  item;
    public InfiniteScrollCollection<Group<string, Model>> Item 
    {
                get { return item; }
                set { this.Set("Item", ref item, value); }
    }
    

    Is there a something missing?

    Thanks for the possible response.

  • ColeXColeX Member, Xamarin Team Xamurai
    edited October 2018

    Should i use Observable Collection instead Infinity Scroll Collection?

    No need , InfiniteScrollCollection derives from ObservableCollection.

    Is there a something missing?

    I can't see the complete code e,g CallWebServiceAsync.

    Can you follow the usage of sample :https://github.com/mattleibow/InfiniteScrolling/tree/master/InfiniteScrollingApp ?

Sign In or Register to comment.