Skip to content

Instantly share code, notes, and snippets.

@DamianSuess
Created August 1, 2018 13:09
Show Gist options
  • Save DamianSuess/1f053440d98d485cb3e2eab8fd9088ab to your computer and use it in GitHub Desktop.
Save DamianSuess/1f053440d98d485cb3e2eab8fd9088ab to your computer and use it in GitHub Desktop.
Xamarin.Forms - Password hide/show
<Entry x:Name="Email" Placeholder="Email" TextColor="Black" Grid.Row="1" Grid.Column="1"></Entry>
<StackLayout Grid.Row="2" Grid.Column="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Entry IsPassword="True" x:Name="Password" TextColor="Black" Placeholder="Password" Grid.Column="0" Grid.ColumnSpan="2" />
<Image Source="eye32.png" HorizontalOptions="End" VerticalOptions="Center" Grid.Column="1">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="ShowPass" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</Grid>
</StackLayout>
public void ShowPass(object sender, EventArgs args)
{
Password.IsPassword = Password.IsPassword ? false : true;
}
/*
FYI for non-xamarin WinForms
https://www.codeproject.com/Articles/660751/PasswordEye-Control
*/
@dev-khurramshahzad
Copy link

Very helpful Thanks.

@DamianSuess
Copy link
Author

@dev-khurramshahzad Happy to be of assistance, you're welcome.

@fabg49
Copy link

fabg49 commented Oct 13, 2022

Very easy of all the ones I have seen. Thank yoy

@SamuelJoseBolanoMejia
Copy link

I spent 2 days looking for something like this, and in 5 minutes I did it. Thank you

@DamianSuess
Copy link
Author

DamianSuess commented Aug 14, 2023

Happy to help @SamuelJoseBolanoMejia. It's good to know these are useful and to keep creating snips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment