private void AddTaskButton_Click(object sender, RoutedEventArgs e) { AddTask addTask = new AddTask { Owner = this }; if (addTask.ShowDialog() == true) { RadioButton radio = addTask.GroupBox.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked == true); int ww = Int32.Parse(radio.Tag.ToString()); Importance imp = (Importance)ww; Task task = new Task((Category)addTask.CategoryComboBox.SelectedItem, false, (String)addTask.CreationDate.Content, addTask.date, imp, addTask.Steps); Tasks.Add(task); db.AddTask(task); } }