This documentation is archived and is not being maintained.

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)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public int MaxLength { get; set; }
/** @property */
public int get_MaxLength ()

/** @property */
public void set_MaxLength (int value)

public function get MaxLength () : int

public function set MaxLength (value : int)

<object MaxLength="int" .../>

Property Value

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).

Identifier Field

MaxLengthProperty

Metadata Flags

None

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

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;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: