如何在Windows Phone中显示带提示文字的密码框?
我尝试了PasswordBox
和Toolkit's PhoneTextBox
。将这两者结合起来有什么特别之处吗?
答案 0 :(得分:7)
为此,我现在正在使用http://damianblog.com/2011/01/21/wp7-password-watermark/。我希望能有更好的方法。
答案 1 :(得分:3)
另一种选择:WindowsPhoneControls
此外,Telerik WP控件的下一个版本还有一个RadPasswordTextBox。
答案 2 :(得分:0)
也许,尝试编辑phonetextbox的控件模板。用passwordbox替换文本框。
你可以获得一个密码盒版手机文本框,LOL
答案 3 :(得分:0)
您可以创建自己的WatermarkedPasswordBox,它将从PasswordBox传递。这并不困难。此链接将为您提供帮助:
答案 4 :(得分:0)
恩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();
}
快乐编码!