private void CheckAllChildrens(PlantillaPlanaItem item, bool checkValue, bool checkTodos) { PlantillaPlanaItem.PlantillaPlanaItemTipo targetType = ((item.Tipo == PlantillaPlanaItem.PlantillaPlanaItemTipo.Plantilla) ? (PlantillaPlanaItem.PlantillaPlanaItemTipo.Modulo) : ((item.Tipo == PlantillaPlanaItem.PlantillaPlanaItemTipo.Modulo) ? (PlantillaPlanaItem.PlantillaPlanaItemTipo.Agrupador) : (PlantillaPlanaItem.PlantillaPlanaItemTipo.Variable))); PlantillaViewModel model = (PlantillaViewModel)this.DataContext; if (checkTodos) { model.PlantillaPlana.Items.Where(x => x.ParentId == item.Id && x.Tipo == targetType).ToList().ForEach(p => p.Todo = checkValue); if (checkValue) { model.PlantillaPlana.Items.Where(x => x.ParentId == item.Id && x.Tipo == targetType).ToList().ForEach(p => p.UltimoResultado = false); } } else { model.PlantillaPlana.Items.Where(x => x.ParentId == item.Id && x.Tipo == targetType).ToList().ForEach(p => p.UltimoResultado = checkValue); if (checkValue) { model.PlantillaPlana.Items.Where(x => x.ParentId == item.Id && x.Tipo == targetType).ToList().ForEach(p => p.Todo = false); } } }
private void ChkUltimoResultado_Checked(object sender, RoutedEventArgs e) { var chk = sender as CheckBox; PlantillaPlanaItem item = chk.DataContext as PlantillaPlanaItem; if (item != null) { if (item.Tipo != PlantillaPlanaItem.PlantillaPlanaItemTipo.Variable) { CheckAllChildrens(item, chk.IsChecked.Value, false); } if (chk.IsChecked.Value) { item.Todo = false; } } }