Windows Dev Center

EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

Control.IsEnabled property

Gets or sets a value indicating whether the user can interact with the control.

Syntax


public bool IsEnabled { get; set; }


<control IsEnabled="bool"/>

Property value

Type: System.Boolean [.NET] | Platform::Boolean [C++]

true if the user can interact with the control; otherwise, false.

Remarks

Many controls have predefined visual states that are invoked for IsEnabled=false, such as "graying out" text in labels.

Whenever IsEnabled changes, that fires the IsEnabledChanged event. Controls might handle this event in order to change the visual states. The event has DependencyPropertyChangedEventArgs data, so you can determine the old and new values without having to use your own flags.

A control inherits the IsEnabled property from its parent control. For example, if a control that contains a button has IsEnabled set to false, the button's IsEnabled property is also false. When the parent's property changes, that fires IsEnabledChanged for each control where the value changes because of the value inheriting.

How the control logic behaves when disabled is potentially different for each control. However, these behaviors will result in all controls when IsEnabled=false:

  • The control can't receive keyboard focus or be focused programmatically.
  • The control does not appear in a tab sequence (any value for TabIndex is ignored).
  • A disabled control is still visible to hit testing. It can't handle any input events on itself. However, a disabled control can still source the input events, and input routed events can bubble to a parent where they can be handled.

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

Control
IsEnabledChanged
IsTabStop
Visibility

 

 

Mostrar:
© 2015 Microsoft