WPF 4.0 中数据绑定的实现方式有什么变化吗?
我在早期版本的 WPF 项目中使用了数据绑定。我使用了 wpf 工具包中的 DataGrid,并使用 DataGridTextColumn 和 DataGridTemplateColumn 以及其中的 DatePicker 和 ComboBox 来更新特定单元格的值。我已将其与实现 INotifyPropertyChanged 接口的业务对象绑定。早些时候,此功能运行良好,但最近我们迁移到 WPF 4.0,此功能不起作用。我收到错误消息“双向绑定需要 Path 或 XPath。”我的业务对象的字段也没有得到更新。 WPF 4.0 中的数据绑定有什么变化吗?请帮忙!!
I have used data binding in my project in earlier version of WPF. I have used DataGrid from wpf toolkit and used DataGridTextColumn and DataGridTemplateColumn with DatePicker and ComboBox inside it to update particular cell's value. I have bound it with a business object that implements INotifyPropertyChanged interface. Earlier this was working fine but recently we moved to WPF 4.0 and this functionality is not working. I am getting error message "Two-way binding requires Path or XPath." and fields of my business objects are also not getting updated. Is there any change in Data Binding in WPF 4.0? Please help!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与 .NET 3.5 相比,.NET 4 中数据绑定的工作方式没有(重大)变化。但是,如果您使用框架的 DataGrid 类而不是 WPF 工具包的 DataGrid,则该控件本身会发生变化。
我怀疑这是由于您最初实施该控件的方式存在问题造成的。您应该使用
{Binding}
而不是{Binding Path=Something}
指定 Binding,这不太可能完全符合您的预期,至少在没有为相关对象准备好数据模板。There are no (significant) changes to how Data Binding works in .NET 4 vs. .NET 3.5. However, if you're using the Framework's DataGrid class instead of the WPF Toolkit's DataGrid, there are changes in that control itself.
I suspect this is due to a problem in how you were implementing that control originally. You should be specifying a Binding using
{Binding}
and not{Binding Path=Something}
, which isn't likely to be exactly what you intended, at least not without a data template in place for the object in question.