How can I toggle hiding/showing password characters with EnablePasswordVisibilityToggle=True?

I know I can set the EnablePasswordVisibilityToggle on a SfTextInputLayout to mask password characters and add a toggle for the mask, but if the user taps log in with their password unmasked, it doesn't seem that I can force the password characters to be masked while the login is processed. Is there a way to do this, or do I need to use a custom implementation?


7 Replies 1 reply marked as answer

ET Eswaran Thirugnanasambandam Syncfusion Team January 18, 2022 02:47 PM UTC

Hi Andrew Hoke, 
 
Greetings from Syncfusion.  
 
We can achieve this requirement by accessing the IsPassword property of the InputView (Entry) directly and setting it as true when clicking the login button as mentioned in the below code snippet. 
 
[C#] 
private void Button_Clicked(object sender, EventArgs e) 
{ 
    var inputView = til.InputView as Entry; 
    if (inputView != null && !inputView.IsPassword) 
    { 
        inputView.IsPassword = true; 
    } 
} 
 
We have prepared sample for the same. Please get the sample from the below link. 
 
Regards, 
Eswaran 



AH Andrew Hoke July 20, 2022 12:21 AM UTC

" We can achieve this requirement by accessing the IsPassword property of the InputView (Entry) directly and setting it as true when clicking the login button as mentioned in the below code snippet. "


I have tried this and it does not work. The password remains unmasked. I have ensured that the PropertyChanged event is fired on the view model to force the Entry to update IsPassword



ET Eswaran Thirugnanasambandam Syncfusion Team July 20, 2022 08:01 PM UTC

We would like to inform that the IsPassword property binding of the InputView (Entry) is working correctly when it is changed dynamically. Could you please confirm whether your requirement is to mask the password text when clicking the login button. If your requirement is different from this, please revert with more details about your requirements. It will help us provide an appropriate solution at the earliest. Please get the tested sample from the below attachment.


Attachment: GSTextInputLayout_1b842e66.zip

Marked as answer

AH Andrew Hoke July 20, 2022 08:15 PM UTC

Yes, the requirement is to mask the password text when logging in if the user chooses to unmask the password text using the visibility toggle provided by SfTextInputLayout. I have tried dynamically setting IsPassword on the Entry to True upon the user tapping the log in button but the password remains unmasked.



ET Eswaran Thirugnanasambandam Syncfusion Team July 21, 2022 01:53 PM UTC

As mentioned earlier, the password text is masked correctly when the login button is clicked. We have prepared a video to show that the IsPassword property binding of the InputView (Entry) is working correctly when it is changed dynamically. Please get the tested video from the below attachment.


If you still face any problem, can you revert us by modify the previously provided sample along with the replication steps/video. It will help us provide an appropriate solution at the earliest.


Attachment: Demovideo_c704a353.zip


AH Andrew Hoke July 21, 2022 02:27 PM UTC

It seems that setting the binding mode to TwoWay was the key difference between my code and your sample. Thanks for providing that. With setting the binding mode on IsPassword to TwoWay, it now works when clicking log in.



ET Eswaran Thirugnanasambandam Syncfusion Team July 22, 2022 07:27 AM UTC

We are glad to hear that you have achieved your requirement. Please get in touch with us if you require any further assistance.


Loader.
Up arrow icon