Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Item Appearing event of list view not working correctly in xamarin.forms

$
0
0

Hi

I have a list view in a page and pagination implemented in it .

The concept of item appearing event is the event will fire only when the particular list cell appears in the screen . But in my case i have done pagination for 100 items and initially in my ipad i can see 4 items and when i scroll up i could see the below cells and only if the last cell appears on the screen api call should go to fetch next 100 items.But here on loading the page itself the item appearing event is firing for all 100 items before i scroll.Why is it happening?

async void LoadingPaginationListItems(object Sender, ItemVisibilityEventArgs e)
{

        ObservableCollection<demo> ListItems = (ObservableCollection<demo>)ListView.ItemsSource;
        var item = (demo)e.Item;

        if (item != null && ListItems.Last().SampleNo.Equals(item.SampleNo)           
            && (ListItems.Count >= 100))
        {
            DemoPageModel obj = new DemoPageModel();           
            var result = await obj.PaginationListItems();  //api call
            foreach (var lsItem in result)
            {
                ListItems.Add(lsItem);
            }

          ListView.ItemsSource = ListItems;              
            _userDialogs.HideLoading();
        }


    }

Please help me to solve this....


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>