public void SetLayout(MainFieldType _mainFieldType) { BindingContext = this; MinimumHeightRequest = 20; caption = new Label() { //IsVisible = false, Opacity = 0, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start }; caption.SetBinding(Label.TextColorProperty, new Binding("TextColor")); caption.SetBinding(Label.TextProperty, new Binding("CustomPlaceholder")); caption.SetBinding(Label.FontSizeProperty, new Binding("CaptionFontSize")); caption.SetBinding(Label.FontFamilyProperty, new Binding("CustomFontFamily")); entryField = new CustomEntry() { PlaceholderColor = CustomColors.PlaceholderColor, BorderTypes = CustomEntry.BorderType.None, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center }; entryField.SetBinding(Entry.TextProperty, "Value", BindingMode.TwoWay); //BindingMode.TwoWay, null, null); entryField.SetBinding(Entry.TextColorProperty, new Binding("TextColor")); entryField.SetBinding(Entry.PlaceholderColorProperty, new Binding("TextColor")); entryField.SetBinding(Entry.PlaceholderProperty, new Binding("CustomPlaceholder")); entryField.SetBinding(Entry.FontFamilyProperty, new Binding("CustomFontFamily")); entryField.SetBinding(Entry.KeyboardProperty, new Binding("CustomKeyboard")); entryField.TextChanged += OnEntryFieldTextChanged; pickerField = new CustomPicker() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center }; //pickerField.ItemsSource = pickerField.SetBinding(Picker.TextColorProperty, new Binding("TextColor")); pickerField.SetBinding(Picker.TitleProperty, new Binding("CustomPlaceholder")); pickerField.SetBinding(Picker.FontSizeProperty, new Binding("CaptionFontSize")); pickerField.SetBinding(Picker.FontFamilyProperty, new Binding("CustomFontFamily")); pickerField.SetBinding(Picker.ItemsSourceProperty, new Binding("ItemsSource")); pickerField.SelectedIndexChanged += OnItemSelected; stackFieldsHolder = new StackLayout() { Children = { caption }, Padding = new Thickness(2), Margin = new Thickness(2), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; switch (_mainFieldType) { case MainFieldType.EntryField: stackFieldsHolder.Children.Add(entryField); break; case MainFieldType.PickerField: stackFieldsHolder.Children.Add(pickerField); break; default: break; } stackMainHolder = new RoundEdgeStackLayout() { Children = { stackFieldsHolder }, Margin = new Thickness(2), GradientDirection = GradientStyle.None, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; stackMainHolder.SetBinding(RoundEdgeStackLayout.StartColorProperty, new Binding("CustomEntryBackGroundColor")); stackMainHolder.SetBinding(RoundEdgeStackLayout.EndColorProperty, new Binding("CustomEntryBackGroundColor")); stackMainHolder.SetBinding(RoundEdgeStackLayout.BorderColorProperty, new Binding("BorderColor")); stackMainHolder.SetBinding(RoundEdgeStackLayout.HasBorderColorProperty, new Binding("ShallAddBorder")); stackMainHolder.SetBinding(RoundEdgeStackLayout.BorderThicknessProperty, new Binding("BorderThickness")); //stackMainHolder.SetBinding(RoundEdgeStackLayout.PaddingProperty, new Binding("EntryTextPadding")); stackMainHolder.SetBinding(RoundEdgeStackLayout.CornerRadiusProperty, new Binding("CornerRadius")); Content = stackMainHolder; }
public CustomEntryGroup(MainFieldType _mainFieldType) { mainFieldType = _mainFieldType; SetLayout(_mainFieldType); }