MaxLength Property

PasswordBox.MaxLength Property

 

Gets or sets the maximum length for passwords to be handled by this PasswordBox.

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

public int MaxLength { get; set; }

Property Value

Type: System.Int32

An integer specifying the maximum length, in characters, for passwords to be handled by this PasswordBox.

A value of zero (0) means no limit.

The default value is 0 (no length limit).

This property only restricts passwords entered manually by the user; it has no effect on programmatic manipulation of the Password property.

Identifier field

MaxLengthProperty

Metadata properties set to true

None

The following example shows how to set the MaxLength attribute of a PasswordBox element.

<PasswordBox
  Name="pwdBox" 
  MaxLength="64"
  PasswordChar="#"
  PasswordChanged="PasswordChangedHandler"  
/>

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

// Set the new maximum input length for passwords to 128 characters.
pwdBox.MaxLength = 128;

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