The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
PasswordBox.MaxLength Property
Silverlight
Gets or sets the maximum length for passwords to be handled by this PasswordBox.
Namespace: System.Windows.Controls
Assembly: System.Windows (in System.Windows.dll)
<PasswordBox MaxLength="int"/>
Property Value
Type: System.Int32An integer specifying the maximum length, in character, for passwords to be handled by this PasswordBox.
A value of zero (0) means no limit.
The default value is 0 (no length limit).
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The property is set to a negative value. |
Dependency property identifier field: MaxLengthProperty
This property only restricts password entered manually by the user; it has no effect on programmatic manipulation of the Password property.
The following snippet sets the MaxLength property to 8. This example is part of a larger example available in the PasswordBox class overview.
<TextBlock Text="Type password here" Margin="20,10,0,0"/> <PasswordBox x:Name="MyPWBox1" Margin="20,10,0,0" PasswordChanged="MyPWBox1_PasswordChanged" MaxLength="8" Height="35" Width="200" HorizontalAlignment="Left" /> <TextBlock Text="Password" Margin="20,10,0,0"/> <TextBox x:Name="ReadOnlyTB" Margin="20,10,0,0" HorizontalAlignment="Left" IsReadOnly="True" Height="35" Width="200" />
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.