Secure Password with Password Box Control: WPF

September 09, 2013 , , , 0 Comments

Textbox is used to input simple string type values and some alphanumeric values. What is inserted in the textbox, can be read by the user easily. But when we are creating the login form or any form for security purposes, then we have to hide the text/value written by the user.

For these purposes textbox doesn’t have a password mode in WPF, so we have to use password box in place of textbox. Password box is designed to enter password by the user because, the colleague can’t read the inputted value by us. It doesn’t allow editing options like cut, copy and paste etc.
<Label Content="Password" Width="200" Height="25"></Label>
<PasswordBox Width="200" Height="25"/>

By using the above code, a password box has been created and when we will write something into this, it will be converted into bullets. The bullets are the standard password character format of windows now like in windows 8.

Secure password using password box in WPF

We can change some of the properties of this password box, which are mostly used in WPF:
  • PasswordChar: used to change the password character. <PasswordBox Width="200" Height="25" PasswordChar="*"/>
  • MaxLength: limit the length of the password. <PasswordBox Width="200" Height="25" MaxLength=”6”/>

Subhash Sharma

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google