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

Notify ViewModel that Entry in SfListvIew has changed.

Hi,

I did read a lot about behaviors but can't find a solution.

I have a SfListView with several Enry's.in it.



Hiw can i achive that the ViewModel has been notified when the value of the Entry has changed?

Best regards,

Thijs van Rijswijk

1 Reply

DB Dinesh Babu Yadav Syncfusion Team May 9, 2019 08:45 AM UTC

Hi Thijs, 
 
Thanks for contacting Syncfusion support. 
 
You can wire the data model’s property changed event in your ViewModel class to get notification the whenever the property text in Entry gets changed like below code example. For your reference, we have attached the sample with this code snippet, please find the link below. 
 
 
Code Example[C#] 
 
public class ContactsViewModel : INotifyPropertyChanged 
{ 
                               
        public ContactsViewModel (SfListView listview) 
        { 
            ListView = listview; 
            contactitems = new ObservableCollection<Contacts>(); 
            LoadData(12); 
        } 
 
        public void LoadData(int count) 
        { 
            for (int i = 0; i < 10; i++) 
            { 
                var contact = new Contacts(CustomerNames[i], r.Next(720, 799).ToString() + " - " + r.Next(3010, 3999).ToString()); 
                contact.ContactColor = Color.FromRgb(r.Next(40, 255), r.Next(40, 255), r.Next(40, 255)); 
                contact.ContactImage = ImageSource.FromResource("SfListViewSample.Images.Image" + r.Next(0, 28) + ".png"); 
                ContactItems.Add(contact); 
                contact.PropertyChanged += Contact_PropertyChanged; 
            } 
            ListView.DataSource.DisplayItems.CollectionChanged += DisplayItems_CollectionChanged; 
        } 
 
        private void Contact_PropertyChanged(object sender, PropertyChangedEventArgs e) 
        { 
            var name = e.PropertyName; 
            App.Current.MainPage.DisplayAlert("Message","Modified Property Name :" +name,"Ok"); 
        } 
 
        private void DisplayItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
        { 
            App.Current.MainPage.DisplayAlert("Message", "Collected gets changed","Ok"); 
 
        } 
} 
 
 
Please let us know if your need any further assistance. 
 
Regards, 
Dinesh Babu Yadav 
 


Loader.
Live Chat Icon For mobile
Up arrow icon