private void AddContactCommand(object sender) { var contactForm = new ContactForm(); ContactViewModel dataContext = ((ContactViewModel)contactForm.DataContext); dataContext.ContactInfo = new Contact(); contactForm.ShowDialog(); GetAllContacts(); }
private void UpdateContactCommand(object sender) { var selectedContacts = (from c in Contacts where c.IsSelected select c).ToList(); if (selectedContacts.Count == 1) { var contactForm = new ContactForm(); var viewModel = (ContactViewModel)contactForm.DataContext; viewModel.ContactInfo = selectedContacts[0]; viewModel.ContactId = selectedContacts[0].ContactId; viewModel.FirstName = selectedContacts[0].FirstName; viewModel.LastName = selectedContacts[0].LastName; viewModel.EmailAddress = selectedContacts[0].EmailAddress; viewModel.PhoneNumber = selectedContacts[0].PhoneNumber; viewModel.Status = selectedContacts[0].Status; contactForm.ShowDialog(); GetAllContacts(); } }