WPF 绑定到 IDataErrorInfo.Error 属性设计时问题

发布于 2024-11-29 15:56:53 字数 502 浏览 6 评论 0原文

我想将 TextBox.Text 绑定到我的对象 IDataErrorInfo.Error 属性,该属性返回错误摘要。我的对象是 DataContext。 现在我有一个这样的文本框:

<TextBox xmlns:sys="clr-namespace:System.ComponentModel;assembly=System" Text="{Binding Path=(sys:IDataErrorInfo.Error), Mode=OneWay}" />

并且在运行时一切正常,但在设计时 Visual Studio 2010 显示错误:“Binding”上引发了 InvalidOperationException:对象“null”不能用作 PropertyPath 的访问器参数。访问器必须是 DependencyProperty、PropertyInfo 或 PropertyDescriptor。 现在出现此错误(在黄色栏中),我无法使用属性工具箱来编辑我的窗口。 任何人都可以帮我解决这个错误吗?

I want to Bind a TextBox.Text to my object IDataErrorInfo.Error property that return summary of errors. My object is DataContext.
Now i've a textbox like that:

<TextBox xmlns:sys="clr-namespace:System.ComponentModel;assembly=System" Text="{Binding Path=(sys:IDataErrorInfo.Error), Mode=OneWay}" />

and all works fine at runtime but at design time Visual Studio 2010 show an error: InvalidOperationException was thrown on "Binding": Object 'null' cannot be used as an accessor parameter for a PropertyPath. An accessor must be DependencyProperty, PropertyInfo, or PropertyDescriptor.
Now with this error (in yellow bar) i can not use property toolbox to edit my windows.
Anyone can help me solve this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁吢 2024-12-06 15:56:53

你能试试这个吗
<代码>
Text="{绑定路径=错误,模式=OneWay}"

Can you try this

Text="{Binding Path=Error, Mode=OneWay}"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文