protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Picker> e) { base.OnElementChanged(e); if (this.Control != null) { this.Control.BorderStyle = UITextBorderStyle.None; if (this.Element is CustomPicker customPicker) { this.Control.TextAlignment = TextAlignmentHelper.Convert(customPicker.HorizontalTextAlignment); if (customPicker.SelectedItem == null && !string.IsNullOrEmpty(customPicker.Placeholder)) { this.Control.Text = null; this.Control.AttributedPlaceholder = new NSAttributedString(customPicker.Placeholder, foregroundColor: customPicker.PlaceholderColor.ToUIColor()); } if (customPicker.MultilineEnabled) { var nativePicker = Control.InputView as UIPickerView; nativePicker.Delegate = new MyPickerDelegate( () => Element.Items.ToList(), () => customPicker.PickerRowHeight, (selectedIndex) => this.Element.SelectedIndex = selectedIndex); } } } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e) { base.OnElementChanged(e); if (this.Control != null) { this.Control.BorderStyle = UITextBorderStyle.None; if (this.Element is CustomDatePicker customDatePicker) { this.Control.TextAlignment = TextAlignmentHelper.Convert(customDatePicker.HorizontalTextAlignment); if (!customDatePicker.Date.HasValue && !string.IsNullOrEmpty(customDatePicker.Placeholder)) { this.Control.Text = null; this.Control.AttributedPlaceholder = new NSAttributedString(customDatePicker.Placeholder, foregroundColor: customDatePicker.PlaceholderColor.ToUIColor()); } if (UIDevice.CurrentDevice.CheckSystemVersion(13, 2)) { try { UIDatePicker picker = (UIDatePicker)Control.InputView; picker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels; } catch (Exception) { } } } } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e) { base.OnElementChanged(e); if (this.Control != null) { this.Control.BorderStyle = UITextBorderStyle.None; if (this.Element is CustomDatePicker customDatePicker) { this.Control.TextAlignment = TextAlignmentHelper.Convert(customDatePicker.HorizontalTextAlignment); if (!customDatePicker.Date.HasValue && !string.IsNullOrEmpty(customDatePicker.Placeholder)) { this.Control.Text = null; this.Control.AttributedPlaceholder = new NSAttributedString(customDatePicker.Placeholder, foregroundColor: customDatePicker.PlaceholderColor.ToUIColor()); } } } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Picker> e) { base.OnElementChanged(e); if (this.Control != null) { this.Control.BorderStyle = UITextBorderStyle.None; if (this.Element is DoublePicker doublePicker) { this.Control.TextAlignment = TextAlignmentHelper.Convert(doublePicker.HorizontalTextAlignment); if (doublePicker.SelectedItem == null && !string.IsNullOrEmpty(doublePicker.Placeholder)) { this.Control.Text = null; this.Control.AttributedPlaceholder = new NSAttributedString(doublePicker.Placeholder, foregroundColor: doublePicker.PlaceholderColor.ToUIColor()); } } } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Picker> e) { base.OnElementChanged(e); if (this.Control != null) { this.Control.Background = new ColorDrawable(AndroidGraphics.Color.Transparent); this.Control.SetPadding(4, 0, 0, 0); if (this.Element is CustomPicker customPicker) { this.Control.Gravity = TextAlignmentHelper.ConvertToGravityFlags(customPicker.HorizontalTextAlignment); if (customPicker.SelectedItem == null && !string.IsNullOrEmpty(customPicker.Placeholder)) { this.Control.Text = null; this.Control.Hint = customPicker.Placeholder; this.Control.SetHintTextColor(customPicker.PlaceholderColor.ToAndroid()); } } } }