private void UpdateCourses(object sender, SelectionChangedEventArgs e) { if (DepartmentsComboBox.SelectedIndex == -1) { CoursesComboBox.ItemsSource = null; return; } var sqlParams = new[] { new SqlParameter { ParameterName = "@DepartmentId", Value = Departments[DepartmentsComboBox.SelectedIndex].DepartmentId } }; var courses = SqlServer.SqlServer.ExecuteStoredProcedure(_connectionString, _userCredential, "GetCoursesByDepartment", "Courses", sqlParams).Tables["Courses"].Rows; Courses = Course.GetCollection(courses); CoursesComboBox.ItemsSource = Courses.Select(c => c.CourseName).ToList(); }