xamarin.formsandroid-softkeyboardcursor-position

Xamarin Forms how to set the cursor and focus back to an Entry without triggering or disabling the keyboard?


I have a Xamarin.Forms application, I want my Entry field to re-focus or the Cursor position is set to zero without triggering the soft-keyboard after pressing Enter, I have a hardware scanner that scans barcodes and it returns automatically, so I want to refocus the same entry field programmatically without triggering the keyboard unless I tap on it?

I have seen it in a program I have, but I couldn't do it, Please help me guys, I'm new to this amazing field.


Solution

  • Thanks Jessie and everyone, I found a good easy solution even though it took me a couple of days to find it, I would like to paste it here because it might be useful to someone.

    I just used

    myEntry.Text = "";

    myEntry.SelectionLength = 1;

    you can also do it using MVVM, which is what I did

    this way my barcode scanner would press Enter automatically and my Entry is cleared and the cursor position is set to zero automagically without the keyboard popping up, and if I needed the keyboard at anytime I can just tap on my Entry and it pops up again.