/// <summary> /// Handler for clicking "delete category" /// </summary> /// <param name="sender"></param> /// <param name="e">Event arguments</param> public void DeleteCategoryButton_Click(object sender, RoutedEventArgs e) { // Creating new dialog DeleteCategoryDialog deleteCatDialog = new DeleteCategoryDialog(categoriesList); deleteCatDialog.Owner = this; bool?result = deleteCatDialog.ShowDialog(); // Handlind result if (result == true) { Category c = (Category)deleteCatDialog.CB_Categories.SelectedItem; bool success = SafeDatabase.DeleteCategoryFromDataBase(c); if (success) { categoriesList.Remove(c); if (CB_Categories.SelectedItem == c) { CB_Categories.SelectedIndex = 0; } CB_Categories.Items.Remove(c); } else { DeleteCategoryButton_Click(sender, e); } } }