protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (Control != null) { Control.BorderStyle = UITextBorderStyle.None; var entry = sender as Entry; if (Control.InputAccessoryView == null && entry?.ReturnType == ReturnType.Next) { var keyboardWidth = UIScreen.MainScreen.Bounds.Width; var accessoryView = new UIToolbar(new RectangleF(0, 0, (float)keyboardWidth, 44)) { BarStyle = UIBarStyle.Default, Translucent = true }; var keyboardButtons = SHProperties.GetKeyboardButtons(entry); var prevButton = new UIBarButtonItem(ImageHelper.ImageFromFont(SHIcon.ChevronUp, UIColor.Black, new CGSize(28, 25)), UIBarButtonItemStyle.Done, (o, a) => { MessagingCenter.Send(entry, "Previous"); }); prevButton.Enabled = keyboardButtons == Controls.Enums.KeyboardButton.Both || keyboardButtons == Controls.Enums.KeyboardButton.Prev || keyboardButtons == Controls.Enums.KeyboardButton.BothNoClear; var nextButton = new UIBarButtonItem(ImageHelper.ImageFromFont(SHIcon.ChevronDown, UIColor.Black, new CGSize(28, 25)), UIBarButtonItemStyle.Done, (o, a) => { MessagingCenter.Send(entry, "Next"); }); nextButton.Enabled = keyboardButtons == Controls.Enums.KeyboardButton.Both || keyboardButtons == Controls.Enums.KeyboardButton.Next || keyboardButtons == Controls.Enums.KeyboardButton.BothNoClear; accessoryView.SetItems(new[] { prevButton, nextButton }, false); Control.InputAccessoryView = accessoryView; } } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (Control != null) { var picker = sender as Picker; var toolbar = Control?.InputAccessoryView as UIToolbar; if (picker?.StyleId == "NextPrevious" && toolbar != null && toolbar.Items.Length == 2) { var keyboardButtons = SHProperties.GetKeyboardButtons(picker); var spacerButton = toolbar.Items[0]; var prevButton = new UIBarButtonItem(ImageHelper.ImageFromFont(SHIcon.ChevronUp, UIColor.Black, new CGSize(28, 25)), UIBarButtonItemStyle.Done, (o, a) => { MessagingCenter.Send(picker, "Previous"); }); prevButton.Enabled = keyboardButtons == Controls.Enums.KeyboardButton.Both || keyboardButtons == Controls.Enums.KeyboardButton.Prev || keyboardButtons == Controls.Enums.KeyboardButton.BothNoClear; var nextButton = new UIBarButtonItem(ImageHelper.ImageFromFont(SHIcon.ChevronDown, UIColor.Black, new CGSize(28, 25)), UIBarButtonItemStyle.Done, (o, a) => { MessagingCenter.Send(picker, "Next"); }); nextButton.Enabled = keyboardButtons == Controls.Enums.KeyboardButton.Both || keyboardButtons == Controls.Enums.KeyboardButton.Next || keyboardButtons == Controls.Enums.KeyboardButton.BothNoClear; var clearButton = new UIBarButtonItem("Clear", UIBarButtonItemStyle.Done, (o, a) => { MessagingCenter.Send(picker, "Clear"); }); if (keyboardButtons == Controls.Enums.KeyboardButton.BothNoClear) { toolbar.SetItems(new[] { prevButton, nextButton }, false); } else if (keyboardButtons == Controls.Enums.KeyboardButton.None) { toolbar.SetItems(new[] { spacerButton, clearButton }, false); } else { toolbar.SetItems(new[] { prevButton, nextButton, spacerButton, clearButton }, false); } } } }