How to display a password box with hint text in windows phone?
I have tried the PasswordBox
and Toolkit's PhoneTextBox
. Is there anything special to be done to combine the two?
How to display a password box with hint text in windows phone?
I have tried the PasswordBox
and Toolkit's PhoneTextBox
. Is there anything special to be done to combine the two?
For this I am using http://damianblog.com/2011/01/21/wp7-password-watermark/ for now. I hope to get a better method.
Another option: WindowsPhoneControls
Also, the next release of the Telerik WP controls has a RadPasswordTextBox.
Maybe , try to edit phonetextbox's control template . replace the textbox with passwordbox.
and you can get a passwordbox edition phonetextbox , LOL
You can create your own WatermarkedPasswordBox which will be deliver from PasswordBox. It is not difficult. This link will help you :
In Windows Phone 8 using Windows Phone Toolkit
En Xaml
<Grid Grid.Row="1" Margin="12,0,0,0" x:Name="ContentPanel">
<toolkit:PhoneTextBox Height="72" Margin="0,0,0,270" TextWrapping="Wrap" VerticalAlignment="Bottom" Hint="{Binding LocalizedResources.LblUser, Source={StaticResource LocalizedStrings}}" x:Name="txtUser" />
<toolkit:PhoneTextBox Height="72" Margin="0,0,0,210" TextWrapping="Wrap" Hint="{Binding LocalizedResources.LblPassword, Source={StaticResource LocalizedStrings}}" x:Name="txtPasswordPlace" VerticalAlignment="Bottom" IsReadOnly="True" />
<PasswordBox Margin="0,72,0,210" VerticalAlignment="Bottom" x:Name="txtPassword" LostFocus="PasswordLostFocus" GotFocus="PasswordGotFocus" Opacity="0"/>
<Button x:Name="btnLogin" Content="{Binding LocalizedResources.LblStartSession, Source={StaticResource LocalizedStrings}}" Click="BtnLogin_Click" VerticalAlignment="Bottom" Margin="0,0,0,150" />
</Grid
En C#
public void CheckPasswordWatermark()
{
var passwordEmpty = string.IsNullOrEmpty(txtPassword.Password);
txtPasswordPlace.Opacity = passwordEmpty ? 100 : 0;
txtPassword.Opacity = passwordEmpty ? 0 : 100;
}
private void PasswordGotFocus(object sender, RoutedEventArgs e)
{
txtPasswordPlace.Opacity = 0;
txtPassword.Opacity = 100;
}
private void PasswordLostFocus(object sender, RoutedEventArgs e)
{
CheckPasswordWatermark();
}
Happy Coding!
© 2022 - 2024 — McMap. All rights reserved.