PasswordBox.Password Property
May 02, 2013
Gets or sets the password currently held by the PasswordBox.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
<PasswordBox Password="string"/>
Property Value
Type: System.StringA string representing the password currently held by the PasswordBox.
The default value is Empty.
| Exception | Condition |
|---|---|
| ArgumentNullException | The property is set to a Nothing value. |
Setting this property to a Nothing reference (Nothing in Visual Basic) causes the underlying password to be set to Empty.
The following code snippet sets the password to "HelloWorld" using the Password property. This example is part of a larger example available in the PasswordBox class overview.
Security Note: |
|---|
Avoid hard-coding a password within your source code. |
<TextBlock Text="PasswordChar demonstration" Margin="20,10,0,0"/> <PasswordBox x:Name="MyPWBox2" Margin="20,10,0,0" Height="70" Width="200" Password="HelloWorld" HorizontalAlignment="Left"/> <PasswordBox x:Name="MyPWBox3" Margin="20,10,0,0" Height="70" Width="200" Password="HelloWorld" PasswordChar="$" HorizontalAlignment="Left"/>
Security Note: