如何在Windows Phone中显示带有提示文本的密码框?
我已经尝试了PasswordBox
和Toolkit's PhoneTextBox
.将两者结合起来有什么特别的要做吗?
,我现在正在使用 http://damianblog.com/2011/01/21/wp7-password-watermark/。我希望得到更好的方法。
另一种选择:WindowsPhoneControls
此外,Telerik WP控件的下一个版本有一个RadPasswordTextBox。
也许,尝试编辑电话文本框的控件模板。 将文本框替换为密码框。
你可以得到一个密码盒版手机文本框,大声笑
您可以创建自己的水印密码框,该框将从密码框提供。这并不难。此链接将帮助您:
http://www.c-sharpcorner.com/UploadFile/74f20d/create-a-watermark-textbox-effect-from-window-phone-7/
8 中使用 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();
}
祝您编码愉快!