UIElement.IsEnabled プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ユーザー インターフェイス (UI) でこの要素が有効かどうかを示す値を取得または設定します。 これは依存関係プロパティです。
public:
property bool IsEnabled { bool get(); void set(bool value); };
public bool IsEnabled { get; set; }
member this.IsEnabled : bool with get, set
Public Property IsEnabled As Boolean
要素が有効になっている場合に true
します。それ以外の場合は、false
します。 既定値は true
です。
次の例は、1 つのボタンのハンドラーを示しています。このハンドラーを実行すると、別の名前付きボタンに IsEnabledfalse
が設定 b1
。
public partial class RoutedEventAddRemoveHandler {
void MakeButton(object sender, RoutedEventArgs e)
{
Button b2 = new Button();
b2.Content = "New Button";
// Associate event handler to the button. You can remove the event
// handler using "-=" syntax rather than "+=".
b2.Click += new RoutedEventHandler(Onb2Click);
root.Children.Insert(root.Children.Count, b2);
DockPanel.SetDock(b2, Dock.Top);
text1.Text = "Now click the second button...";
b1.IsEnabled = false;
}
void Onb2Click(object sender, RoutedEventArgs e)
{
text1.Text = "New Button (b2) Was Clicked!!";
}
Public Partial Class RoutedEventAddRemoveHandler
Private Sub MakeButton(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim b2 As Button = New Button()
b2.Content = "New Button"
AddHandler b2.Click, AddressOf Onb2Click
root.Children.Insert(root.Children.Count, b2)
DockPanel.SetDock(b2, Dock.Top)
text1.Text = "Now click the second button..."
b1.IsEnabled = False
End Sub
Private Sub Onb2Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
text1.Text = "New Button (b2) Was Clicked!!"
End Sub
このプロパティは、実行時に多くの場合、特定の要素に対する IsEnabledCore のクラス固有の実装の影響を受けます。 そのため、ここで示す既定値は有効でない場合があります。 たとえば、スクロール バーをサポートする必要がないと判断されるたびに、ScrollBar が IsEnabledfalse
されます。 この値を設定しようとすると、IsEnabledCoreによって返される値によってオーバーライドされる可能性もあります。
有効になっていない要素はヒット テストやフォーカスに参加しないため、入力イベントのソースになりません。
識別子フィールド | IsEnabledProperty |
true に設定されたメタデータ プロパティ |
何一つ |
製品 | バージョン |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。