private void BuildParametroComboboxGenerico( ComandoParametroDto paramItem , ref TableSection paramDiv ) { try { String[] opt = paramItem.Dominio.Split(';'); List <FormularioDinamicoElementDto> dataSource = new List <FormularioDinamicoElementDto>(); foreach (String item in opt) { String[] dataTemp = item.Split('|'); dataSource.Add(new FormularioDinamicoElementDto() { Id = dataTemp[0], Text = dataTemp[1] }); } CustomPickerCell entry = new CustomPickerCell() { DataSource = dataSource, ItemDisplayBinding = new Binding("Text"), CellLabel = paramItem.Label }; if (!String.IsNullOrWhiteSpace(paramItem.Valor)) { entry.CellText = paramItem.Valor; } ListParametros.Add( paramItem.IdParametro.ToString() , entry ); entry.Tapped += Entry_Tapped; paramDiv.Add(entry); } catch { } }
public List <ComandoParametroDto> RecuperaValor() { List <ComandoParametroDto> lstReturn = new List <ComandoParametroDto>(); try { Dictionary <Int32, ComandoParametroDto> dic = new Dictionary <int, ComandoParametroDto>(); foreach (KeyValuePair <String, Cell> item in Form.ListParametros) { ComandoParametroDto temp; String[] parts = item.Key.Split('-'); Int32 idParametro = Convert.ToInt32(parts[0]); if (dic.ContainsKey(idParametro)) { temp = dic[idParametro]; dic.Remove(idParametro); } else { temp = new ComandoParametroDto() { IdParametro = idParametro }; } String valor = ""; Type tipo = item.Value.GetType(); Layout <View> tempView; if (tipo == typeof(CustomSwitchCell)) { CustomSwitchCell tempCell = (CustomSwitchCell)item.Value; tempView = (Grid)tempCell.View; } else if (tipo == typeof(CustomPickerCell)) { CustomPickerCell tempCell = (CustomPickerCell)item.Value; tempView = (StackLayout)tempCell.View; } else { CustomEntryCell tempCell = (CustomEntryCell)item.Value; tempView = (StackLayout)tempCell.View; } foreach (View itemView in tempView.Children) { Type tipoChildren = itemView.GetType(); if (tipoChildren != typeof(Label)) { if (tipoChildren == typeof(Switch)) { valor = Convert.ToInt32(((Switch)itemView).IsToggled).ToString(); } else if (tipoChildren == typeof(Picker)) { FormularioDinamicoElementDto tempPicker = ((Picker)itemView).SelectedItem as FormularioDinamicoElementDto; if (tempPicker != null) { valor = tempPicker.Id; } } else { valor = ((Entry)itemView).Text; } break; } } temp.Valor += valor; dic.Add(temp.IdParametro, temp); } lstReturn = dic.Values.ToList(); } catch { } return(lstReturn); }