Information
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.

Button.IsDefaulted Property

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

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public bool IsDefaulted { get; }

Property Value

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

Identifier field

IsDefaultedProperty

Metadata properties set to true

None

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.

NoteNote

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.

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

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft