private void ModifyPassword() { if (_SelectedPasswordIndex == -1) { MessageBox.Show(_View, "No selected password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } PasswordEntry entry = _Passwords[_SelectedPasswordIndex]; NewPasswordView passwordView = new NewPasswordView(entry) { Owner = _View }; try { if (passwordView.ShowDialog() == true) { entry.Save(); MessageBox.Show(_View, "Modified password successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(_View, "Modification Cancelled", "Cancelled", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } catch { MessageBox.Show(_View, "Problem modifying the password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public NewPasswordViewModel(NewPasswordView view, PasswordEntry entry = null) { _ExistingEntry = entry != null; _View = view; _Model = entry ?? new PasswordEntry(); _OKCommand = new DelegateCommand(OnOk, DataCompleted); }
protected override void Execute() { NewPasswordView passwordView = new NewPasswordView() { Owner = _View }; if (passwordView.ShowDialog() == true) { AddPassword(passwordView.ViewModel.Model); } }