protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); StackLayout stack = new StackLayout() { Margin = 0, Padding = MarginStack, Spacing = 0 }; if (!String.IsNullOrWhiteSpace(CellLabel)) { Label tempLabel = new Label() { Text = CellLabel, FontSize = CellFontSize, LineBreakMode = LineBreakMode.WordWrap, Margin = MarginLabel }; stack.Children.Add(tempLabel); } Picker entry = new Picker() { ItemDisplayBinding = ItemDisplayBinding, ItemsSource = DataSource, Margin = MarginEntry }; if (!String.IsNullOrWhiteSpace(CellPlaceholder)) { entry.Title = CellPlaceholder; } if (!String.IsNullOrWhiteSpace(CellText)) { FormularioDinamicoElementDto temp = DataSource.FirstOrDefault(x => x.Id == CellText); entry.SelectedItem = temp; } stack.Children.Add(entry); Label errorLabel = new Label() { TextColor = Color.Red, FontSize = CellFontSizeMenor, LineBreakMode = LineBreakMode.WordWrap }; stack.Children.Add(errorLabel); View = stack; }
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); }