how can i get visible items in the syncfusion list view?

We would like to inform you that you can get the items created on load from the Children property of the VisualContainer. Also, you can get the information of the last visible item using the VisualContainer.ScrollRows.LastBodyVisibleLineIndex property.

The VisualContainer.Children will have the details of the visible items.

public class Behavior : Behavior<ContentPage> 
    { 
        SfListView ListView; 
        VisualContainer VisualContainer; 
     
        protected override void OnAttachedTo(ContentPage bindable) 
        { 
            ListView = bindable.FindByName<SfListView>("listView"); 
            VisualContainer = ListView.GetVisualContainer(); 
            ListView.ScrollStateChanged += ListView_ScrollStateChanged; 
            base.OnAttachedTo(bindable); 
        } 
     
        private void ScrollView_Scrolled(object sender, ScrolledEventArgs e) 
        { 
        } 
     
        private void ListView_ScrollStateChanged(object sender, ScrollStateChangedEventArgs e) 
        { 
            if (e.ScrollState == ScrollState.Idle) 
            { 
                var visibleItems = VisualContainer.Children; 
                var lastVisibleItem = VisualContainer.ScrollRows.LastBodyVisibleLineIndex; 
            } 
        } 
    } 

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top