ListView recycling issue

Hi, my team and I are using the SfListView control with a GridLayout to display data passed in through the binding context. We are currently experiencing issues with the recycling of the cells.

Initially, however many are able to fit on the device's screen are rendered correctly, but after scrolling, the next templates to be rendered will be a duplicate of the initially rendered data. So if three out of the nine elements in our data list are able to fit on the device's screen when the listview is initially rendered, when you scroll down to the next three, it is a repeat of the first three that were initially visible upon load. The data has been checked and is the correct list, it just seems to be an issue with the recycling of the cells that is causing the duplicates.The only solution that we have been able to find so far has been refreshing the entire list and allowing it to reload after every scroll the user does. This is extremely intensive and causes scrolling to be extremely slow, and essentially impossible.

Any ideas of how we can fix this issue or what exactly is causing it?

Thanks.

5 Replies 1 reply marked as answer

LN Lakshmi Natarajan Syncfusion Team June 4, 2020 09:41 AM UTC

Hi Josh, 
 
Thank you for using Syncfusion products. 
 
We have checked the reported query “ListView recycling issue” from our end. We would like to inform you that the SfListView is completely developed with UI Virtualization(Item recycling) concept and it only creates the element only which are in view on initial loading. While scrolling, we have cache the created elements and recycled it by updating only the BindingContext of the SfListView item. We suspect that the binding is not updated properly in your application on scrolling. Please let us know the following details regarding the same, 
 
Could you please ensure whether the items in the SfListView is binded with the model property? 
Could you please ensure whether INotifyPropertyChaged is implemented for properties? 
 
If you still facing the same issue, then we suggest you to handle the recycle of the ListViewItems in sample level using the following APIs. By default, ListView reuses items on scrolling and source collection change. To skip reusing while scrolling, set the ListViewCachingStrategy property as CreateNewTemplate for the ListView. Please refer the following API details,  
  
API  
Values  
Description  
ListViewCachingStrategy- to skip the reusing for scrolling.  
CreateNewTemplate  
Creates new element for every data in ItemsSource.  
  
RecycleTemplate  
Reuses elements on scrolling.   
  
Default value: RecycleTemplate  
ItemsSourceChangeCachingStrategy - to skip the reusing of list items on items source property changed.  
RecycleItems  
The ListView items will be recycled on ItemsSource changes.  
  
Default value: RecycleItems  
  
ClearItems  
The existing ListView items will be cleared and create new list items when ItemsSource changed.  
 
Please let us know the solution we have provided was helpful. If not, please revert us back with the ListView related templates and issue reproducing video if possible which would be helpful for us to check on it and provide you the solution as soon as possible. 
 
Regards, 
Lakshmi Natarajan 
 



RK Radoslaw Kubas June 4, 2020 10:55 AM UTC

Hello,

Could you advice me solution for my case? I have custom control inside SfListView.

<customControls:PriceDisplay 
     Value="{Binding Share}" 
     HasFocus="{Binding Source={x:Reference BehaviorShare}, Path=IsChecked}">
                                                                                                      
     <customControls:PriceDisplay.Behaviors>
          <behavious:RadioBehavior x:Name="BehaviorShare" GroupName="SplitPage" />
     </customControls:PriceDisplay.Behaviors>

</customControls:PriceDisplay>

"Value" binding works fine, but I have recycle view problem with "HasFocus", when scrolling "HasFocus" not changing. I guess because event if BindingContext is changed, "Source" is still same. I would like to use full recycle strategy because speed is very nice, but it would be perfect to find any solution for this. Any advice would be amazing. 

Thank you in advance!

Best regards,
Radoslaw kubas


LN Lakshmi Natarajan Syncfusion Team June 5, 2020 01:26 PM UTC

Hi Radoslaw, 
 
Thank you for using Syncfusion products. 
 
We have checked the reported query “Binding is not updated properly in SfListView” from our end. We would like to inform you that the behavior class is same for all the items, we need to update all the properties to resolve the reported scenario. We have prepared sample based on the code snippets provided and updated the IsChecked property using BindingContextChanged event. Please refer the following code snippets for more reference, 
 
Behavior: 
public class Behavior : Behavior<Grid> 
{ 
    private bool isChecked; 
    public bool IsChecked 
    { 
        get 
        { 
            return isChecked; 
        } 
        set 
        { 
            isChecked = value; 
            this.OnPropertyChanged(); 
        } 
    } 
 
    protected override void OnAttachedTo(Grid bindable) 
    { 
        bindable.BindingContextChanged += Bindable_BindingContextChanged; 
        base.OnAttachedTo(bindable); 
    } 
 
    private void Bindable_BindingContextChanged(object sender, EventArgs e) 
    { 
        if (((sender as Grid).BindingContext as Contacts).ContactName == "William") 
            IsChecked = true; 
        else 
            IsChecked = false; 
    } 
} 
 
We have attached the tested sample in the following link, 
 
Please let us know if you need further assistance. 
 
Regards, 
Lakshmi Natarajan 
 


Marked as answer

RK Radoslaw Kubas June 5, 2020 02:07 PM UTC

Thank you very much for this hint!

Best regards,
Radoslaw Kubas


LN Lakshmi Natarajan Syncfusion Team June 5, 2020 02:48 PM UTC

Hi Radoslaw, 
  
Thank you for the update. 
  
We are glad that our solution meets your requirement. Please let us know if you need any further update. As always we are happy to help you out. 
  
Regards, 
Lakshmi Natarajan 
 


Loader.
Up arrow icon