when i enter some text on password field and tap on outside of the password field again come back to the password field previous text is getting cleared, i don't want to clear the previous text.
when i enter some text on password field and tap on outside of the password field again come back to the password field previous text is getting cleared, i don't want to clear the previous text.
Hello @SWAPNILGAIKWAD-3135 ,
Welcome to our Microsoft Q&A platform!
To prevent changing the pervious text when focusing the entry, try to create a custom Entry renderer to set UITextFieldDelegate for it. You could override the ShouldChangeCharacters method to change the behavior in the custom delegate class.
Check the code:
[assembly: ExportRenderer(typeof(Entry), typeof(CustomEntryRenderer))]
namespace TestApplication_6.iOS
{
public class CustomEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control.SecureTextEntry)
{
Control.Delegate = new CustomTextFieldDelegate();
}
}
}
internal class CustomTextFieldDelegate : UITextFieldDelegate
{
public override bool ShouldChangeCharacters(UITextField textField, NSRange range, string replacementString)
{
string updatedString = textField.Text.Substring(0, (int)range.Location) + replacementString + textField.Text.Substring((int)(range.Location + range.Length));
textField.Text = updatedString;
return false;
}
}
}
Best Regards,
Jarvan Zhang
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.
8 people are following this question.