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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ListVIew visible line or item

Thread ID:

Created:

Updated:

Platform:

Replies:

142565 Feb 10,2019 10:56 PM UTC Feb 11,2019 07:29 AM UTC Xamarin.Forms 1
loading
Tags: SfListView
David
Asked On February 10, 2019 10:56 PM UTC

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

Jayaleshwari N [Syncfusion]
Replied On 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. 
 
Regards, 
Jayaleshwari N. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;