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.