Password Property

PasswordBox.Password Property


Gets or sets the password currently held by the PasswordBox.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public string Password {

Property Value

Type: System.String

A string representing the password currently held by the PasswordBox.

The default value is Empty.

When you get the Password property value, you expose the password as plain text in memory. To avoid this potential security risk, use the SecurePassword property to get the password as a SecureString.

Setting this property to null causes the underlying password to be set to Empty.

The following example shows how to set the Password property programmatically.

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2015 Microsoft