C# WPF IsEnabled 使用多个绑定? [英] C# WPF IsEnabled using multiple bindings?

查看:29
本文介绍了C# WPF IsEnabled 使用多个绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个描述 GUI 部分的 WPF xaml 文件,我希望启用/禁用特定控件依赖于其他两个控件.代码现在看起来像这样:

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 一起使用.请参阅此处: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

这是一个直接相关的例子: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆