Button.IsDefaulted 屬性

定義

取得值,這個值表示 Button 按鈕是否可在使用者按下 ENTER 鍵時啟動。

public:
 property bool IsDefaulted { bool get(); };
public bool IsDefaulted { get; }
member this.IsDefaulted : bool
Public ReadOnly Property IsDefaulted As Boolean

屬性值

如果該按鈕可在使用者按下 ENTER 鍵時啟動,則為 true,否則為 false。 預設為 false

範例

下列範例示範如何判斷屬性 true 是否 IsDefaulted 適用于預設按鈕。

if (btnDefault.IsDefault == true)
{
    btnDefault.Content = "This is the default button.";
}
if (btnDefault.IsDefaulted == true)
{
    btnDefault.Content = "The button is defaulted.";
}
If (btnDefault.IsDefault = True) Then

    btnDefault.Content = "This is the default button."

    If (btnDefault.IsDefaulted = True) Then

        btnDefault.Content = "The button is defaulted."
    End If
End If

備註

IsDefaulted 屬性設定為 true ,且具有焦點的控制項不接受 ENTER 做為輸入時 IsDefault , 屬性 true 就是 。 例如,在 [ 執行 ] 對話方塊中, [確定 ] 按鈕是預設按鈕。 當焦點位於文字方塊上時, IsDefaulted 在 [ 確定 ] 按鈕上,是因為 true 使用者可以按 ENTER 來啟動按鈕。

注意

如果預設按鈕有焦點, IsDefaulted 則 為 false 。 這是因為 方法會 OnKeyDown 處理 ENTER,而且不需要 IsDefaulted 將 設定為 true

相依性屬性資訊

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

適用於