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

Append Items to SfListView Manually in Descending order

Hi,

I have the below SfListView in my MAUI app


It has two Labels and one Image (from Image Source).

The data is inserted to the SfListView every second using Dispatcher.CreateTimer()

How can I insert items to the SfListView without having to refresh it and to make sure the last inserted items show first so the user doesn't need to scroll to the end just to see the recent item.


Thanks,

Jassim



1 Reply

SY Suthi Yuvaraj Syncfusion Team March 9, 2023 03:28 PM UTC

Hi Jassim,


# Regarding Refresh listview while adding items ,


We would like to let you know that , it is necessary to refresh the listview while adding the items to update UI view, if you are adding the bulk items to list, you can invoke the BeginInit() and EndInit() method to restrict the refresh action for each item added and refresh the list after adding the item.


Please refer the below documentation for more reference.

UG Link: https://help.syncfusion.com/maui/listview/working-with-sflistview#improving-listview-performance



#Regarding Adding and scroll to new item


SfListView allows you to add the item at desire position by using the insert() method, Please refer the code snippet for more information


Code snippet:

void Button_Clicked(System.Object sender, System.EventArgs e)

    {

        vm.Items.Insert(0, new Item

        {

            Name = "NewItem"

        });

    }


Also If you want to scroll to the new item , you can use programmatic scrolling of listview to scroll to desired position, the below documentation explains about the Programmatic scrolling ,


UG Link: https://help.syncfusion.com/maui/listview/scrolling#programmatic-scrolling


Please let us know if you have any concern,


Regards,

Suthi Yuvaraj.


Loader.
Live Chat Icon For mobile
Up arrow icon