动态更新数据网格中的各个单元格
我有一个可观察的出租车集合。 Taxi 类具有 Taxi_No、Name、Current_Locn、Bill_Amount 等属性。
我已将可观察集合绑定到 wpf 数据网格。当在集合中添加或删除出租车时,更改会反映在数据网格中。但随着出租车在城市中行驶,出租车的位置会发生变化(Current_Locn),账单金额也会发生变化。然而,这些变化并不会动态地反映在网格中。
据我所知,可观察集合仅跟踪集合的更改。但是,如何跟踪集合中每个数据项的单独属性?我应该对每个属性实施 INotifyPropertyChanged 吗?在这种情况下如何将其绑定到网格?
I have an observable collection of Taxis. The Taxi class has properties like Taxi_No, Name, Current_Locn, Bill_Amount.
I have bound the observable collection to a wpf data grid. As a taxi is added or deleted from the collection, the changes are reflected in the data grid. But as the taxi moves through the city the location of the taxi changes(Current_Locn) and so does the bill amount. However, these changes are not dynamically reflected in the grid.
I understand that observable collection keeps only track of changes to the collection. But, how do I keep track of individual properties of each data item in the collection? Should I implement INotifyPropertyChanged on each property? and how do I bind it to the grid in such a case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只需要在 Taxi 类上实现 INotifyPropertyChanged 即可。
I just need to implement INotifyPropertyChanged on the Taxi class.