Disable scroll animation while maintaining the same scroll position of SfListView while updating ItemsSource at runtime

Can we disable the scroll animation that occurswhile trying to maintain the same scroll position of SfListView while updating ItemsSource at runtime by using technique mentioned in :

4 Replies

MK Muthu Kumaran Gnanavinayagam Syncfusion Team November 18, 2017 02:11 PM UTC

Hi Samir, 
 
We have checked the reported query “Need to disable the scrolling animation while changing the ItemsSource” from our side. You can achieve your requirement by using ScrollToRowIndex method where we have provided option to disable to animation while scrolling. You can get the value of ScrollLineIndex from the ScrollAxisBase in VisualContainer of SfListView before changing the ItemsSource. You can pass the value of ScrollLineIndex to ScrollToRowIndex and disable the animation while scrolling down the list as like below code example. 
 
Code example[C#]: 
public partial class MainPage : ContentPage 
    { 
        VisualContainer visualContainer; 
 
        public MainPage() 
        { 
            InitializeComponent(); 
            visualContainer = listView.GetVisualContainer(); 
        } 
 
        private void ChangeItemsSource_Clicked(object sender, EventArgs e) 
        { 
            var scrollLineIndex = visualContainer.ScrollRows.ScrollLineIndex; 
            var viewmodel = new ContactsViewModel(); 
            listView.ItemsSource = viewmodel.EmployeeInfo; 
            listView.LayoutManager.ScrollToRowIndex(scrollLineIndex, true); 
        } 
    } 
 
Note: This code example is applicable only after SfListView (v15.4.017). 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 



MO Morten July 7, 2019 03:45 PM UTC

Can you provide a working downloadable sample of this? I can't get it to work.


DB Dinesh Babu Yadav Syncfusion Team July 8, 2019 11:18 AM UTC

Hi Morten, 
 
Apologies for the inconvenience. 
 
In the latest SfListView version, we could able to replicate the reported issue and we have logged a defect report for this. The fix for the issue will be available on the 30th July, 2019 weekly Nuget. You can track the status of the report from the following link. 
 
 
We will let you know once the issue has been resolved and include in the weekly Nuget. We will appreciate your patience until then. 
 
Please let us know if you require further assistance. 
 
Regards, 
Dinesh Babu Yadav 



DB Dinesh Babu Yadav Syncfusion Team July 26, 2019 05:44 AM UTC

Hi Morten, 
 
Apologize for the inconvenience. 
 
After deeply analyzing the reported issue, we would like to let you know that the reported issue is not a defect and you can achieve the requirement in the application itself. Because, when the ItemsSource is changed at runtime, the items are being generated and ListView will update its items in UI. So, ScrollToRowIndex method won’t scroll the items at this time. So, we request you to perform the scroll to operation in a main thread with minimal delay to complete the layout process as like below code example, 
 
Code Example [C#]: 
Device.BeginInvokeOnMainThread(async () => 
{ 
   await Task.Delay(200); 
   listView.LayoutManager.ScrollToRowIndex(scrollLineIndex, true); 
}); 
 
 
For your reference, we have prepared the sample with above code example  
 
Regret for this inconvenience. Please let us know if you require further assistance. 
 
Regards, 
Dinesh Babu Yadav 


Loader.
Up arrow icon