コード例 #1
0
        public void btnSubmitClick(object sender, EventArgs e)
        {
            var    bindingContext = BindingContext as NewContactViewModel;
            string newContactName = entryNewName.Text;

            if (!String.IsNullOrEmpty(newContactName))
            {
                var contactsList = bindingContext.ContactsList;
                contactsList.Add(ContactsLocalRepository.AddNewContact(newContactName));
                bindingContext.ContactsList = new ObservableCollection <Contact>(contactsList.OrderByDescending <Contact, string>(x => x.DisplayName));
                //TODO: il nuovo item viene aggiunto in coda alla lista e neanche OrderBy ha effetto
            }
            Navigation.PopAsync();
        }
コード例 #2
0
 public ContactsViewModel()
 {
     _contactsList = new ObservableCollection <Contact>();
     _searchText   = "";
     ContactsList  = ContactsLocalRepository.ReadAll();
 }