public NumericEntryQuantityQuestionInputView(QuantityQuestion question, SurveyPageAppearance appearance) : base(appearance) { _question = question; var stackLayout = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Spacing = 10 }; _entry = BuildValueEntry (question); stackLayout.Children.Add (_entry); if (question.HasUnitOptions) { _picker = BuildUnitPicker (question); stackLayout.Children.Add (_picker); } SetUIFromResponse (); // set event handlers AFTER populating _question.PropertyChanged += Question_PropertyChanged; _entry.TextChanged += Entry_TextChanged; if (_picker != null) { _picker.PropertyChanged += Picker_PropertyChanged; } Content = stackLayout; }
protected virtual OptionValuePicker BuildUnitPicker(QuantityQuestion question) { var picker = new OptionValuePicker { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.CenterAndExpand, PlaceholderText = "Unit", ItemsSource = question.UnitOptions }; picker.Value = question.UnitOptions.FirstOrDefault (x => x.Value == question.DefaultUnit); return picker; }
public PickerOptionQuestionInputView(OptionQuestion question, SurveyPageAppearance appearance) : base(appearance) { var picker = new OptionValuePicker (); picker.HorizontalOptions = LayoutOptions.StartAndExpand; picker.VerticalOptions = LayoutOptions.CenterAndExpand; picker.PlaceholderText = question.Text; picker.BindingContext = question; picker.ItemsSource = question.OptionValues; picker.SetBinding (OptionValuePicker.ValueProperty, new Binding ("SelectedOption", BindingMode.TwoWay)); Content = picker; }
public SliderQuantityQuestionInputView(SliderQuantityQuestion question, SurveyPageAppearance appearance) : base(appearance) { _question = question; var vStack = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill }; var valueStack = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill, IsVisible = false }; if (question.IsValueVisible) { _valueLabel = BuildValueLabel (question); valueStack.Children.Add (_valueLabel); valueStack.IsVisible = true; UpdateValueLabel (); } if (question.HasUnitOptions) { _picker = BuildUnitPicker (question); valueStack.Children.Add (_picker); valueStack.IsVisible = true; } var sliderStack = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill }; _labelledSlider = new LabelledSlider { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center }; if (question.Labels != null && question.Labels.Any ()) { _labelledSlider.Labels.Items = question.Labels; } else { _labelledSlider.Labels.IsVisible = false; } sliderStack.Children.Add (_labelledSlider); vStack.Children.Add (valueStack); vStack.Children.Add (sliderStack); UpdateUI (); // set event handlers AFTER populating _question.PropertyChanged += Question_PropertyChanged; _labelledSlider.Slider.PropertyChanged += Slider_PropertyChanged; if (_picker != null) { _picker.PropertyChanged += Picker_PropertyChanged; } HeightRequest = -1; Content = vStack; }