public void InsertText(string text) { if (SelectionStart == SelectionEnd) { EditableText.Insert(SelectionStart, new Java.Lang.String(text)); } else { EditableText.Replace(SelectionStart, SelectionEnd, new Java.Lang.String(text)); } }
/// <summary> /// This method is called when the text is changed, in case any subclasses would like to know. /// Within text, the lengthAfter characters beginning at start have just replaced old text that /// had length lengthBefore. It is an error to attempt to make changes to text from this callback. /// </summary> /// <param name="text">The text the TextView is displaying</param> /// <param name="start">The offset of the start of the range of the text that was modified</param> /// <param name="before">The length of the former text that has been replaced</param> /// <param name="after">The length of the replacement modified text</param> protected override void OnTextChanged(Java.Lang.ICharSequence text, int start, int before, int after) { base.OnTextChanged(text, start, before, after); if (Text != _currentValue && !(_expression == null || _expression.IsMatch(Text))) { EditableText.Replace(0, Text.Length, _currentValue ?? string.Empty); } if (Text == _currentValue) { return; } var old = _currentValue; _currentValue = Text; this.OnPropertyChanged(nameof(Text)); this.OnPropertyChanged(nameof(StringValue)); OnTextChanged(old, _currentValue); }