PasswordBox.Password Property

 

Gets or sets the password currently held by the PasswordBox.

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

Public Property Password As String

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.

Dim pwdBox As New PasswordBox()
pwdBox.Password = "Open Sesame!"

.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: