PasswordBox.MaxLength 屬性

定義

取得或設定要由這個 PasswordBox 處理的密碼最大長度。

public:
 property int MaxLength { int get(); void set(int value); };
public int MaxLength { get; set; }
member this.MaxLength : int with get, set
Public Property MaxLength As Integer

屬性值

Int32

指定要由這個 PasswordBox 處理之密碼最大長度的整數 (以字元為單位)。

值為零 (0) 表示沒有限制。

預設值為 0 (沒有長度限制) 。

範例

下列範例示範如何設定 MaxLength 專案的 屬性 PasswordBox

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

下列範例示範如何以程式設計方式設定 MaxLength 屬性。

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

備註

此屬性只會限制使用者手動輸入的密碼;它不會影響屬性的程式 Password 設計操作。

相依性屬性資訊

識別碼欄位 MaxLengthProperty
設定為 的中繼資料屬性 true

適用於