private List <Nanny> NannyList(Child child) { try { List <Nanny> nannyList; nannyList = BL_Tool.MatchingNannies(child.ID).ToList(); var boolArray = BL_Tool.MotherRequirements(bl.GetNanny(nannyList[0].ID), child, bl.GetMother(child.MotherID)).Any(n => n == false); this.Dispatcher.Invoke(new Action(() => { nannyDataGrid.ItemsSource = nannyList; nannyDataGrid.RowBackground = boolArray ? new SolidColorBrush(Colors.Yellow) : new SolidColorBrush(Colors.LawnGreen); })); return(nannyList); } catch (Exception e) { MessageBox.Show($"Error - {e.Message}", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); return(new List <Nanny>()); } }