将功能区文本框 IsEnabled 绑定到复选框 IsChecked 不起作用
下面是示例 XAML:
...
<ribbon:RibbonTab Header="MyTab">
<ribbon:RibbonGroup Header="Blah">
<ribbon:RibbonTextBox x:Name="MyTextBox"
IsEnabled="{Binding IsChecked, ElementName=MyCheckBox}" />
<ribbon:RibbonCheckBox x:Name="MyCheckBox" Label="some text" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
...
由于某种原因,无论是否选中该复选框,文本框都保持禁用状态。为什么绑定不能正常工作?
您可以将上面的代码减去顶部和底部的省略号添加到样板 WPF 功能区项目中,看看是否可以找出问题所在。例如,我没有看到任何绑定错误诊断。
更新:如果用常规TextBox
替换RibbonTextBox
,则行为将变得正确。我的结论是,绑定 RibbonTextBox
的 IsEnabled 属性一定存在一些问题。
奇怪的更新 #2:创建一个基本的 RibbonTextBox
并将其 IsEnabled
属性设置为 True
创建一个禁用的 RibbonTextBox。什么给?
我已提交 Microsoft Connect 上的错误报告,以进一步解决此问题。
最终更新:已在 WPF 4.5 中修复。
Here is the sample XAML:
...
<ribbon:RibbonTab Header="MyTab">
<ribbon:RibbonGroup Header="Blah">
<ribbon:RibbonTextBox x:Name="MyTextBox"
IsEnabled="{Binding IsChecked, ElementName=MyCheckBox}" />
<ribbon:RibbonCheckBox x:Name="MyCheckBox" Label="some text" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
...
For some reason, the text box stays disabled regardless of whether or not the check box is checked. Why is the binding not working properly?
You can add the above code minus the elipses at the top and bottom to a boiler plate WPF ribbon project and see if you can figure out what's wrong. I see no binding error diagnostics, for example.
Update: If a regular TextBox
is substituted for the RibbonTextBox
, the behavior becomes correct. I conclude that there must be some issue with binding the IsEnabled property of a RibbonTextBox
.
Freaky update #2: Creating a basic RibbonTextBox
and setting its IsEnabled
property to True
creates a disabled RibbonTextBox. What gives?
I have submitted a bug report on Microsoft Connect to further pursue this issue.
Final update: It's fixed in WPF 4.5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为一个大胆的猜测,您是否尝试过完全鉴定该房产?
...或者甚至...
As a wild guess, have you tried fully qualifying the property?
... or maybe even...