5

如何在 Windows Phone 中显示带有提示文本的密码框?

我已经尝试过PasswordBoxand Toolkit's PhoneTextBox。将两者结合起来有什么特别的吗?

4

5 回答 5

7

为此,我现在使用http://damianblog.com/2011/01/21/wp7-password-watermark/。希望能有更好的方法。

于 2012-10-10T05:52:35.597 回答
3

另一种选择:WindowsPhoneControls

此外,Telerik WP 控件的下一个版本有一个 RadPasswordTextBox。

于 2012-10-15T21:27:34.000 回答
0

在使用Windows Phone 工具包的 Windows Phone 8 中

恩 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

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();
    }

快乐编码!

于 2014-06-23T06:39:32.840 回答
0

也许,尝试编辑phonetextbox的控件模板。用密码框替换文本框。

你可以得到一个密码框版phonetextbox,哈哈

于 2012-10-10T06:58:19.960 回答
0

您可以创建自己的 WatermarkedPasswordBox,它将从 PasswordBox 提供。这并不难。此链接将帮助您:

http://www.c-sharpcorner.com/UploadFile/74f20d/create-a-watermark-textbox-effect-from-window-phone-7/

于 2012-10-12T11:27:26.953 回答