【问题标题】:IsEnabled binding Button and CheckboxIsEnabled 绑定按钮和复选框
【发布时间】:2018-07-04 15:32:51
【问题描述】:

我有一个按钮和一个复选框。 对于这两个IsEnabled 绑定设置为相同的属性:

<CheckBox x:Name="CbShowAll"
          Content="Bla"
          IsEnabled="{Binding WaitForRefresh}" />

<Button x:Name="BtnReload"
       Content="Bla"
       IsEnabled="{Binding WaitForRefresh}" />

如果我更改 WaitForRefresh 属性,按钮会更改其启用状态 - 复选框不会。为复选框手动输入“true”或“false”到IsEnabled,一切正常。

【问题讨论】:

  • 你 100% 确定吗?禁用的复选框看起来很像 wpf 默认主题中启用的复选框
  • 我确定......按钮被禁用(灰色)并且无法单击,而我可以更改复选框的检查......设置 IsEnabled="false" 正是我想要的...... . 但没有约束力。
  • 看起来很奇怪。任何绑定错误?
  • 代码的其他部分“手动”设置 IsEnabled ...该死的...问题可以关闭/删除。
  • 尝试调试代码找到设置IsEnabled属性的语句

标签: c# wpf binding


【解决方案1】:

尝试做这样的事情

IsEnabled="{Binding ElementName=ApplicationWindow, Path=WaitForRefresh}"

其中 ElementName 是您的 WPF 窗口的名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-21
    • 2018-12-06
    • 2012-08-11
    • 1970-01-01
    • 2016-06-22
    • 2015-07-12
    相关资源
    最近更新 更多