PasswordBox.PasswordChar 屬性

定義

取得或設定 PasswordBox 的遮罩字元。

public:
 property char PasswordChar { char get(); void set(char value); };
public char PasswordChar { get; set; }
member this.PasswordChar : char with get, set
Public Property PasswordChar As Char

屬性值

Char

當使用者輸入文字至 PasswordBox 時,會以遮罩字元回應。 預設值為專案符號字元 () 。

範例

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

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

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

// Change the password masking character to a period.
pwdBox.PasswordChar = '.';
' Change the password masking character to a period.
pwdBox.PasswordChar = "."c

備註

當文字輸入至 PasswordBox 時,這個屬性指定的遮罩字元會在密碼輸入欄位中回應,而不是實際的密碼本身。 這有助於防止密碼在輸入時公開給非正式觀察者。

相依性屬性資訊

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

適用於