I have implemented the hide and show password feature for the entry component. It is not working initially, but after one hide and show, it starts working. The icons are changing but the password is not showing. This issue is only on the android platform.
My code:
Xaml.cs:
bool showPassword = true;
private void PasswordIcon_Clicked(object sender, EventArgs e)
{
if (showPassword)
{
password_icon.Source = "ic_show_password_xx.png";
password_entry.IsPassword = false;
showPassword = false;
}
else
{
password_icon.Source = "ic_hide_password_xx.png";
password_entry.IsPassword = true;
showPassword = true;
}
}
Xaml:
<StackLayout Padding="3" Orientation="Horizontal">
<local:CustomEntry
x:Name="password_entry"
IsPassword="True"
Placeholder="Password"
Style="{StaticResource LoginEntryStyle}"/>
<Image
x:Name="password_icon"
Style="{StaticResource LoginEntryImageStyle}"
HorizontalOptions="End"
Source="ic_hide_password_xx.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="PasswordIcon_Clicked"
NumberOfTapsRequired="1">
</TapGestureRecognizer>
</Image.GestureRecognizers>
</Image>
</StackLayout>
Instead of the bool variable, I have tried with password_entry.IsPassword, but no luck. I have uploaded a sample project here for reference.