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

SfListView + DataSource + Realm example

Thread ID:





131552 Jul 17,2017 02:08 AM UTC May 30,2018 12:50 PM UTC Xamarin.Forms 7
Tags: SfListView
Asked On July 17, 2017 02:08 AM UTC


Is there any example with SfListView + DataSource + Realm(Database) + MVVM.
I want to know the correct way to use SfSlistView with those to CRUD and Filter.

I tried but I don't know it's the correct way.

1. I tried to get Realm.All<obj> to ObservableCollection.
2. I set the collection to the listview binding ItemSource.
3. When deleting Item, If I only delete the Realm Object, and reassign the ItemSource to the Realm.All<obj>().ToObservableCollection. it won't refresh the listview, even though I set the DataSource.Refresh().
4. Right now I delete the item in the collection and realm object at the same time, but I don't think it's a good idea.

so is there any example to use all of those tech. to implement CRUD, Filter, Sorting function?

Dinesh Babu Yadav [Syncfusion]
Replied On July 17, 2017 09:56 AM UTC

Hi Seven, 
Thank you for using Syncfusion Products. 
We have checked the reported requirement “SfListView with Realm sample in MVVM pattern” at our end and tried to implement the SfListView control with Realm in MVVM pattern but we are facing the following error “Fody/RealmWeaver: Class Contacts is a RealmObject but has no persisted properties” at our end. So, we have raised a ticket to the respective team to resolve the issue and you can find the link below. 
For your reference, we have attached the prepared sample in which SfListView with Realm in MVVM pattern has been implemented and you can download it from the below link. 
Could you please check with the above sample? If you could able to resolve the issue, we request you to modify the above sample and revert us if the requirement does not met with the additional information’s which would help us to analyze the requirement better and update you an appropriate solution. 
Dinesh Babu Yadav 

Replied On July 19, 2017 06:03 AM UTC


I tried your sample, and I don't think line 78 can work.

contactsinfo = _realm.All<Contacts>() as ObservableCollection<Contacts>;

the cast will make contactsinfo null.

Replied On July 20, 2017 03:28 AM UTC


I still suffer in this thread.

I tried a really easy sample.

Listview worked at Create item and Modify item. but when delete item, it didnt update the listview.

I checked the IEnumerableCollection changed after delete command.

Please give me a hand asap, thanks a lot!!

Attachment: code_snippet_87abda3c.rar

Replied On July 20, 2017 05:29 AM UTC

by the way,

I also use dataSource.Refresh and listview.RefreshView,

The UI display weird.

very suffer to me....

Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On July 24, 2017 03:50 AM UTC

Hi Seven, 
Apologies for the delay. 
We have deeply analyzed the reported query “ListView items does not refresh after deleting the items from Realm collection” at our end. We would like to inform you that the SfListView refreshes the view only when it gets notification whether underlying collection is changed or modified. Adding/removing items through Realm doesn't notify whether the collection is changed and so the view does not update even while calling the RefreshView. So we have to store the realm objects under ObservableCollection(As it provides notification when collection changed) to refresh the view. 
For your assistance, we have attached the working sample link below, 
Please let us know if you further assistance. 
G.Muthu Kumaran. 

Replied On May 27, 2018 08:42 AM UTC

I wonder why it works with the out of the box ListView

thanks in advance

Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On May 30, 2018 12:50 PM UTC

Hi Redhouane, 
We would like to inform you that while modifying the IEnumerable collection(either adding or deleting items at runtime) will update the items list bound to the ItemsSource of ListView. However the View will not be updated as the source collection will not get notified regarding this change. We have checked the same with Xamarin.Forms ListView and found the similar behavior as stated earlier. So you need the store the underlying collection as ObservableCollection to perform Visual changes at runtime in ListView. 
G.Muthu kumaran. 


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

or the page will be automatically redirected to 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