【问题标题】:Is it possible to apply NOT(!) operator while DataBinding a property of a control?是否可以在 DataBinding 控件的属性时应用 NOT(!) 运算符?
【发布时间】:2011-02-21 19:07:19
【问题描述】:

我有 Button 控件,我必须根据 bool 变量设置 IsEanbled 属性。

bool IsBoolVariable

我想如果 IsBoolVariable 属性为 true 那么我想将 IsEnabled 属性设置为 false 并且当IsBoolVariable 属性为 false 然后我想将 IsEnabled 属性设置为 true

是否可以在定义绑定时应用 not(!) 运算符,如下所示

<Button
IsEnabled = "{Binding Path = **!**IsBoolVariable}" />

我可以通过应用转换器很好地做到这一点,但这是唯一的方法吗?

【问题讨论】:

    标签: wpf data-binding wpf-controls


    【解决方案1】:

    你可以将它绑定到一个 bool 属性,当 IsEnabled 为 true 时返回 false....

    【讨论】:

      【解决方案2】:

      简短回答:是的,转换器是唯一的方法。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-10
        • 1970-01-01
        • 2019-07-15
        • 1970-01-01
        • 2011-12-19
        • 1970-01-01
        • 1970-01-01
        • 2014-02-22
        相关资源
        最近更新 更多