private void AddCategory() { CategoryModel newCategory = new CategoryModel(); CategoryValidateViewModel validateVM = new CategoryValidateViewModel(ref newCategory); Views.CategoryValidateView validateView = new Views.CategoryValidateView(); validateView.DataContext = validateVM; validateView.ShowDialog(); if (newCategory.DataIndexes != null && newCategory.Name != null) { try { storageHandler.AddCategory(newCategory); } 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}."); } GetCategories(); } }