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; }
GBEntry BuildValueEntry(QuantityQuestion question) { var entry = new GBEntry { Placeholder = question.Text, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Keyboard = Keyboard.Numeric }; return entry; }
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; }
protected virtual Label BuildValueLabel(QuantityQuestion question) { var label = new Label { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.CenterAndExpand }; return label; }