Forum Xamarin.Forms

ListView.ItemAppearing works for a ViewCell but not triggered for a cell having custom renderer.

harini.5004harini.5004 USMember
edited July 2015 in Xamarin.Forms

The ItemAppearing event for ListView is triggered for a ListView with ViewCell itemTemplate whose item template has not been rendered in iOS or Android but is not triggered when the ViewCell is rendered in iOS or Android?

projectsListView.ItemAppearing += (object sender, ItemVisibilityEventArgs e) => {
Console.WriteLine("Item appearing called");
};
The console message is printed when a "non-rendered" is passed as item template. Observed in Xamarin.Forms 1.4.3. Is it something to be implemented in the renderer?

This implementation is required to find if the list reached the end-of-scroll.Is there any other way in XF to find the same?

Answers

  • hughyuhughyu USMember

    I got the same problem.
    My listview is also using a native custom viewcell renderer.
    https://github.com/xamarin/xamarin-forms-samples/tree/master/WorkingWithListviewNative/WorkingWithListviewNative
    But the ListView's "ItemAppearing" event seems only triggered on Android viewcell renderer but not on iOS.
    Hoping someone could provide a solution or some workaround for this :)

  • JoshuaNovakJoshuaNovak USMember ✭✭

    I'm having the same issue. Anyone figure this out?

  • Confirm issue. Any solution?

  • zechenliuzechenliu USMember ✭✭

    My solution here is renderer the ListView also.

    Use the scroll view delegate method, like this :
    [Export("scrollViewDidScroll:")]
    public void Scrolled(UIScrollView scrollView)
    {
    var height = (Control as UITableView).Frame.Size.Height;
    var distanceFromButton = (Control as UITableView).ContentSize.Height - (Control as UITableView).ContentOffset.Y;

    if (distanceFromButton == height && (Element as LHBaseListView).CanLoadMoreData)        
    {
        if ((Element as LHBaseListView).LoadMoreCommand != null &&
                    (Element as LHBaseListView).LoadMoreCommand.CanExecute(null))
                {
            (Element as LHBaseListView).LoadMoreCommand.Execute(null);
                }   
    }        
    

    }

    To notify list view scroll to the end, and then to notify LoadMoreCommand(self defined) execute.
    if you need to know which item it scrolled to (which item is appearing), i think you need to calculate the item height and list content size.

  • MuthuramMuthuram Member ✭✭

    If anyone solved that issue .Please Let me know guys

  • MuthuramMuthuram Member ✭✭

    I am also facing same issue what should i do please help me out!

Sign In or Register to comment.