问题描述
我有一个WPF xaml文件描述一个GUI的一部分,我想启用/禁用一个特定的控件依赖于另外两个。代码看起来像这样:
I have a WPF xaml file describing a section of a GUI and I'd like the enabling/disabling of a particular control to be dependent on two others. The code looks something like this at the moment:
<ComboBox Name="MyComboBox"
IsEnabled="{Binding ElementName=SomeCheckBox, Path=IsChecked}"/>
但我希望它依赖于另一个复选框,像这样:
But I'd like it to be dependant on another checkbox as well so something like:
<ComboBox Name="MyComboBox"
IsEnabled="{Binding ElementName=SomeCheckBox&AnotherCheckbox, Path=IsChecked}"/>
最好的办法是什么?我不禁感到我错过了一些明显的错误或者错误的方式?
What's the best way to go about that? I can't help feeling I'm missing something obvious or going about this the wrong way?
推荐答案
我相信你可能有使用MultiBinding与MultiValueConverter。请参阅:
I believe you may have to use a MultiBinding with a MultiValueConverter. See here: http://www.developingfor.net/wpf/multibinding-in-wpf.html
这是一个直接相关的示例:
Here is a directly related example: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5b9cd042-cacb-4aaa-9e17-2d615c44ee22
这篇关于C#WPF IsEnabled使用多个绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!