private void EditData() { DataModel newData = new DataModel { Date = SelectedData.Date, Description = SelectedData.Description, Login = SelectedData.Login, Password = SelectedData.Password }; Views.DataValidateView validateView = new Views.DataValidateView(); DataValidateViewModel validateVM = new DataValidateViewModel(ref newData, ref validateView.passwordBox); validateView.DataContext = validateVM; validateView.ShowDialog(); if (!SelectedData.Equals(newData)) { try { storageHandler.ReplaceData(SelectedData, newData); } catch (FileNotFoundException ex) { MessageBox.Show($"File not found {ex.Message}."); } catch (InvalidOperationException ex) { MessageBox.Show($"Can't write data to file {ex.Message}."); } catch (Exception ex) { MessageBox.Show($"Something is wrong {ex.Message}."); } DataChanged(); } }