Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何禁用WPF窗口中除一个按钮外的所有按钮_C#_Wpf_Button - Fatal编程技术网

C# 如何禁用WPF窗口中除一个按钮外的所有按钮

C# 如何禁用WPF窗口中除一个按钮外的所有按钮,c#,wpf,button,C#,Wpf,Button,在我的xaml文件中,我有5个按钮,我想禁用除一个以外的所有按钮 我怎么能做到这一点 注意:我的按钮位于三个堆叠面板中,因此无法使用此答案 这段代码给了我编译错误 foreach (Control ctrl in this.Controls) ctrl.Enabled = false; CancelButton.Enabled = true; 也许再多了解一点? 一种方法是将要控制的所有按钮的IsEnabled属性绑定到“代码隐藏”中的公共属性,然后在需要时设置其值 IsEnable

在我的xaml文件中,我有5个按钮,我想禁用除一个以外的所有按钮

我怎么能做到这一点

注意:我的按钮位于三个堆叠面板中,因此无法使用此答案

这段代码给了我编译错误

foreach (Control ctrl in this.Controls)
    ctrl.Enabled = false;

CancelButton.Enabled = true;
也许再多了解一点? 一种方法是将要控制的所有按钮的IsEnabled属性绑定到“代码隐藏”中的公共属性,然后在需要时设置其值

IsEnabled={Binding Path=IsEnabledProperty}

诸如此类,我现在不能说得更具体,因为我不在工作电脑上,但我相信有人会想出一个支持者的例子;)

绑定Enable以匹配特定枚举这必须在代码隐藏中还是可以在xaml中?