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)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public bool IsDefaulted { get; }
/** @property */
public boolean get_IsDefaulted ()

public function get IsDefaulted () : boolean

You cannot use this property in XAML.

Property Value

true if the button will be activated when the user presses Enter; otherwise, false. The default value is false.

The IsDefaulted property is true when the IsDefault property is set to true and the control that has focus doesn't 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's 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.";
}


Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show: