Password Box with Hint Text
Asked Answered
F

5

5

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?

Familiarize answered 10/10, 2012 at 5:37 Comment(0)
F
7

For this I am using http://damianblog.com/2011/01/21/wp7-password-watermark/ for now. I hope to get a better method.

Familiarize answered 10/10, 2012 at 5:52 Comment(0)
F
3

Another option: WindowsPhoneControls

Also, the next release of the Telerik WP controls has a RadPasswordTextBox.

Foregut answered 15/10, 2012 at 21:27 Comment(0)
C
0

Maybe , try to edit phonetextbox's control template . replace the textbox with passwordbox.

and you can get a passwordbox edition phonetextbox , LOL

Ceramist answered 10/10, 2012 at 6:58 Comment(0)
K
0

You can create your own WatermarkedPasswordBox which will be deliver from PasswordBox. It is not difficult. This link will help you :

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

Karame answered 12/10, 2012 at 11:27 Comment(0)
E
0

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!

Emissive answered 23/6, 2014 at 6:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.