使用C#WPF IsEnabled多个绑定? [英] C# WPF IsEnabled using multiple bindings?
问题描述
我描述一个GUI的部分一个WPF XAML文件,我想一个特定的控制的启用/禁用依赖于两个人。在code看起来像这样的时刻:
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。看这里:<一href=\"http://www.developingfor.net/wpf/multibinding-in-wpf.html\">http://www.developingfor.net/wpf/multibinding-in-wpf.html
I believe you may have to use a MultiBinding with a MultiValueConverter. See here: http://www.developingfor.net/wpf/multibinding-in-wpf.html
下面是直接相关的例子:<一href=\"http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5b9cd042-cacb-4aaa-9e17-2d615c44ee22\">http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5b9cd042-cacb-4aaa-9e17-2d615c44ee22
Here is a directly related example: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5b9cd042-cacb-4aaa-9e17-2d615c44ee22
这篇关于使用C#WPF IsEnabled多个绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!