Button.IsDefaulted Property

Definition

Gets a value that indicates whether a Button is the button that is activated when a user presses ENTER.

C#
public bool IsDefaulted { get; }

Property Value

true if the button is activated when the user presses ENTER; otherwise, false. The default is false.

Examples

The following example shows how to determine whether the IsDefaulted property is true for a default button.

C#
if (btnDefault.IsDefault)
{
    btnDefault.Content = "This is the default button.";
}
if (btnDefault.IsDefaulted)
{
    btnDefault.Content = "The button is defaulted.";
}

Remarks

The IsDefaulted property is true when the IsDefault property is set to true and the control that has focus does not accept ENTER as input. For example, in the Run dialog box, the OK button is the default button. When focus is on the text box, IsDefaulted on the OK button is true because a user can activate the button by pressing ENTER.

Note

If the default button has focus, IsDefaulted is false. This is because the OnKeyDown method handles ENTER, and it is not necessary for IsDefaulted to be set to true.

Dependency Property Information

Item Value
Identifier field IsDefaultedProperty
Metadata properties set to true None

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10