如何刷新数据绑定列表框? [英] How do I refresh a data-bound listbox?

查看:63
本文介绍了如何刷新数据绑定列表框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListBox,其项目绑定到在一个表的一行中找到的数据,但是在通过关系链接的外部表中显示一些数据.我有一个编辑窗口,与选定的ListBoxItem相关联的DataRowView传递到该窗口,从那里我可以编辑文本字段和ID列,这些列和ID列指定该关系应从中获取其他数据的行.当我直接更改在ListBoxItem中显示的文本字段时,只要将更改提交给源,该项目就会在ListBoxItem中更新.但是,如果更改ID字段,从外部行获取的ListBoxItem中的字段不会重新映射到新关系.

如何使ListBox更新其显示的数据?

I have a ListBox whose items are bound to data found in a row of one table, but displays some data in foreign tables linked by relations. I have an edit window to which I pass the DataRowView associated with the selected ListBoxItem, and from there I can edit text fields and the ID columns that specify the row that the relation should grab additional data from. When I directly change a text field that is displayed in the ListBoxItem, that item updates in the ListBoxItem as soon as the change is committed to the source. However, if I change the ID fields, the fields in the ListBoxItem grabbed from the foreign row do not re-map to the new relation.

How can I cause the ListBox to update its displayed data?

推荐答案

只需再次设置ListBox.DataContext.
Just set ListBox.DataContext again.


这篇关于如何刷新数据绑定列表框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆