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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Notify ViewModel that Entry in SfListvIew has changed.

Thread ID:

Created:

Updated:

Platform:

Replies:

144494 May 9,2019 03:36 AM UTC May 9,2019 08:45 AM UTC Xamarin.Forms 1
loading
Tags: SfListView
Thijs van Rijswijk
Asked On May 9, 2019 03:36 AM UTC

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

Dinesh Babu Yadav [Syncfusion]
Replied On 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 
 


CONFIRMATION

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

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

Live Chat Icon For mobile
Live Chat Icon