private void Edit_Click(object sender, RoutedEventArgs e) { Contact selected = vm.Selected; if (selected == null) { return; } Contact contact = new Contact(selected); ContactEditViewModel cvm = new ContactEditViewModel(contact); cvm.Cities = MainModel.Instance.GetCities(); cvm.Persons = MainModel.Instance.GetPersons(); ModernDialog dialog = new ModernDialog { Content = new ContactEditPage(cvm), Title = "Edit Contact" }; dialog.Buttons = new[] { dialog.OkButton, dialog.CancelButton }; if (dialog.ShowDialog() == true) { try { MainModel.Instance.Persist(cvm.Contact); vm.Items = MainModel.Instance.GetContacts(); vm.Message = "Item Presisted"; } catch (Exception ex) { vm.Message = ex.Message; } } }
public ContactEditPage(ContactEditViewModel contactVM) { InitializeComponent(); this.DataContext = contactVM; }