Instead of using the Changed event, I would subclass the EntryElement and override the CreateTextMethod. I use this as a integer only EntryElement, you should be able to adapt this for your task by adding your own event that would get fired when the text length was reached
public class IntegerEntryElement : EntryElement
{
public IntegerEntryElement (string c, string p, string v) : base(c, p, v)
{
_maxLength = 0;
TextAlignment = UITextAlignment.Right;
}
static NSString cellKey = new NSString("IntegerEntryElement");
protected override NSString CellKey { get { return cellKey; } }
private int _maxLength;
public int MaxLength
{
get { return _maxLength; }
set
{
if ((value >= 0) || (value <= 10))
{
_maxLength = value;
}
}
}
public int IntValue
{
get
{
int intValue = 0;
Int32.TryParse(Value, out intValue);
return intValue;
}
set
{
Value = value.ToString();
}
}
public void Clear()
{
Value = "";
}
protected override UITextField CreateTextField (RectangleF frame)
{
RectangleF newframe = frame;
newframe.Width -= 10;
UITextField TextField = base.CreateTextField (newframe);
TextField.KeyboardType = UIKeyboardType.NumberPad;
TextField.ClearButtonMode = UITextFieldViewMode.WhileEditing;
TextField.ShouldChangeCharacters = (UITextField textField, NSRange range, string replacementString) =>
{
bool result = true;
string filter="0123456789";
result = (filter.Contains(replacementString) || replacementString.Equals(string.Empty));
if ((result) && (MaxLength > 0))
{
result = textField.Text.Length + replacementString.Length - range.Length <= MaxLength;
}
return result;
};
return TextField;
}
}