public EntryCellView(RectangleF frame) : base(frame) { KeyboardType = UIKeyboardType.Default; EditModeValue = EditMode.WithCaption; InputView = new UIPlaceholderTextField(new RectangleF(5, 0, frame.Width - 10, frame.Height)) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, BackgroundColor = UIColor.Clear, VerticalAlignment = UIControlContentVerticalAlignment.Center, AutocorrectionType = AutocorrectionType, AutocapitalizationType = AutocapitalizationType, Tag = 1 }; InputView.Started += (s, e) => { if (ClearOnEdit) { InputView.Text = string.Empty; } //DataContextProperty.ConvertBack<string>(); }; InputView.ShouldReturn = UITextField => { InputView.ResignFirstResponder(); return(true); }; InputView.EditingDidEnd += (sender, e) => { if (AutocapitalizationType == UITextAutocapitalizationType.AllCharacters) { InputView.Text = InputView.Text.ToUpper(); } DataContext.Value = InputView.Text; InputView.Text = DataContext.Value.ToString(); }; InputView.EditingDidEndOnExit += (sender, e) => { InputView.ResignFirstResponder(); }; Add(InputView); }
public void DismissKeyboard() { var views = GetFocusableList(); foreach (var view in views) { view.IsNeedsFirstResponder = false; } InputView.ResignFirstResponder(); }
public override void InitializeContent() { if (EditMode != EditMode.ReadOnly) { _InputControl = new UIPlaceholderTextField(new RectangleF(0, 0, Cell.Bounds.Width, Cell.Bounds.Height)) { BackgroundColor = UIColor.Clear, PlaceholderColor = Theme.PlaceholderColor, PlaceholderAlignment = Theme.PlaceholderAlignment, VerticalAlignment = UIControlContentVerticalAlignment.Center, AutocorrectionType = AutoCorrectionType, AutocapitalizationType = AutoCapitalizationType, Tag = 1 }; if (EditMode == EditMode.NoCaption) _InputControl.Placeholder = Caption; else _InputControl.Placeholder = Placeholder; _InputControl.SecureTextEntry = IsPassword; _InputControl.Font = Theme.DetailTextFont; _InputControl.KeyboardType = KeyboardType; _InputControl.TextAlignment = Theme.DetailTextAlignment; _InputControl.ReturnKeyType = ReturnKeyType; if (Theme.DetailTextColor != null) _InputControl.TextColor = Theme.DetailTextColor; _KeyboardToolbar = new UIKeyboardToolbar(this); _InputControl.InputAccessoryView = _KeyboardToolbar; _InputControl.ReturnKeyType = UIReturnKeyType.Default; _InputControl.Started += (s, e) => { //DataContextProperty.ConvertBack<string>(); }; _InputControl.ShouldReturn = delegate { _InputControl.ResignFirstResponder(); return true; }; _InputControl.EditingDidEnd += delegate { DataBinding.UpdateDataContext(); }; ElementView = _InputControl; } }
public EntryCellView(RectangleF frame) : base(frame) { KeyboardType = UIKeyboardType.Default; EditModeValue = EditMode.WithCaption; InputView = new UIPlaceholderTextField(new RectangleF(5, 0, frame.Width - 10, frame.Height)) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, BackgroundColor = UIColor.Clear, VerticalAlignment = UIControlContentVerticalAlignment.Center, AutocorrectionType = AutocorrectionType, AutocapitalizationType = AutocapitalizationType, Tag = 1 }; InputView.Started += (s, e) => { if (ClearOnEdit) { InputView.Text = string.Empty; } //DataContextProperty.ConvertBack<string>(); }; InputView.ShouldReturn = UITextField => { InputView.ResignFirstResponder(); return true; }; InputView.EditingDidEnd += (sender, e) => { DataContext.Value = InputView.Text; InputView.Text = DataContext.Value.ToString(); }; InputView.EditingDidEndOnExit += (sender, e) => { InputView.ResignFirstResponder(); }; Add(InputView); }