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");
}
}
|