Xamarin.Forms Guides | Samples

Xamarin.Forms.VisualElement.IsEnabled Property

Gets or sets a value indicating whether this element is enabled in the user interface. This is a bindable property.

Syntax

public Boolean IsEnabled { get; set; }

Value

true if the element is enabled; otherwise, false. The default value is true

Remarks

Elements that are not enabled do not participate in hit detection, and therefore will not receive focus or emit input events.

The following example shows a handler on a button which will then set IsEnabled to false on another button.

C# Example

  public partial class ButtonDisableExample {
    void BuildButtons ()
    {
      Button button1 = new Button {Text = "New button"};
      Button button2 = new Button {Text = "Disabled on click"};
      button1.Activated += (o, e) => button2.IsEnabled = false;
    }
  }

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0