We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

ListVIew visible line or item

Hi, how I can check if a current item it is visible, so in that way scroll to it to make it visible

1 Reply

JN Jayaleshwari N Syncfusion Team February 11, 2019 07:29 AM UTC

Hi David, 
Thanks for contacting Syncfusion Support. 
We have checked the reported query “How to check if a current item it is visible, so in that way scroll to it to make it visible” from our side. You can achieve your requirement by using VisibleLineInfo method for the selected item. 
private void Bindable_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) 
    var listView = sender as SfListView; 
    if (e.PropertyName == "SelectedItem") 
        var selectedItemIndex = listView.DataSource.DisplayItems.IndexOf(listView.SelectedItem); 
        selectedItemIndex += (listView.HeaderTemplate != null && !listView.IsStickyHeader || !listView.IsStickyGroupHeader) ? 1 : 0; 
        selectedItemIndex -= (listView.GroupHeaderTemplate != null && listView.IsStickyGroupHeader) ? 1 : 0; 
        var visualContainer = listView.GetVisualContainer(); 
        var visibleLineInfo = visualContainer.ScrollRows.GetVisibleLineAtLineIndex(selectedItemIndex); 
        if (visibleLineInfo == null) 
            (listView.LayoutManager as LinearLayout).ScrollToRowIndex(selectedItemIndex); 
We have attached the sample for your reference and you can download the same from the following location. 
You can refer the following article to scroll to the selected item. 
Please let us know if you would require further assistance. 
Jayaleshwari N. 

Live Chat Icon For mobile
Up arrow icon