Hello,
Welcome to our Microsoft Q&A platform!
When you edit the entry, there are two coniderations, delete or add characters, And shouldChangeCharactersInRange
will be executed twice, please try to use Entry's textChange event.
private void MyEntry_TextChanged(object sender, TextChangedEventArgs e)
{
var entry=sender as Entry;
var newValue=e.NewTextValue;
var oldValue=e.OldTextValue;
var CursorPostion= entry.CursorPosition ;
if (oldValue==null)
{
//entry is empty
}
else if(newValue.Length> oldValue.Length)
{
//add value
CursorPostion = entry.CursorPosition+2;
if (CursorPostion< newValue.Length)
{
entry.CursorPosition = CursorPostion;
}
}
else if( newValue.Length < oldValue.Length) {
//delete value
CursorPostion = entry.CursorPosition-2;
if (CursorPostion >0 )
{
entry.CursorPosition = CursorPostion;
}
}
}
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.