public View UpdateAttributesUI(ComosWebSDK.UI.UIOptions ui) { StackLayout stack = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, }; if (!ui.ReadOnly) { editablevalues.Add(ui); } AbsoluteLayout.SetLayoutBounds(stack, new Rectangle( ui.x, ui.y, ui.width, ui.height)); stack.Children.Add(new Label() { Text = ui.Text, WidthRequest = App.WidthPixels / 3, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Start, }); CustomPicker p = new CustomPicker() { HorizontalOptions = LayoutOptions.FillAndExpand, IsEnabled = !ui.ReadOnly, }; foreach (var c in ui.Options.Keys) { p.Items.Add(c); } p.BindingContext = ui; if (ui.CachedValue != "" && ui.CachedValue != ui.Value) { p.SelectedItem = ui.CachedValue; p.TextColor = (Color)App.Current.Resources["spec-only-cache"]; CheckValue(ui.NestedName, ui.CachedValue, ui.Value); } else { p.SelectedItem = ui.Value; } p.SelectedIndexChanged += PickerSelectionChanged; stack.Children.Add(p); return(stack); }
public void PickerSelectionChanged(object sender, EventArgs e) { Picker ctrl = (Picker)sender; ComosWebSDK.UI.UIOptions b = (ComosWebSDK.UI.UIOptions)ctrl.BindingContext; string myPickerNewValue = ctrl.SelectedItem.ToString(); //If picked option does not exist, create new entry in b.Options if (!b.Options.TryGetValue(myPickerNewValue, out myPickerNewValue)) { myPickerNewValue = ctrl.SelectedItem.ToString(); CheckValue(b.NestedName, myPickerNewValue, b.Value, b.Text); } else { CheckValue(b.NestedName, b.Options[ctrl.SelectedItem.ToString()], b.Value, b.Text); } }