VisualElement.IsEnabled 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定值,這個值指出使用者介面中是否已啟用此項目。 這是可繫結屬性。
public bool IsEnabled { get; set; }
member this.IsEnabled : bool with get, set
屬性值
System.Boolean
如果啟用這個項目,則為 true
;否則為 false
。 預設值為 true
備註
未啟用的專案不會參與點擊偵測,因此不會收到焦點或發出輸入事件。
下列範例顯示按鈕上的處理程式,接著在另一個按鈕上將IsEnabled設定為 false。
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;
}
}