如何刷新 Silverlight 控件?
如何刷新 Silverlight 列表框或数据网格?当我绑定项目时,列表框或数据网格不会刷新,直到我在控件内部单击。这很烦人,因为我无法在运行时看到添加的项目。
How can I refresh a Silverlight listbox or datagrid? When I bind items the listbox or datagrid doesn't refresh until I click inside the control. This is annoying as I cannot see added items runtime.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
ObservableCollection
和 < a href="http://msdn.microsoft.com/en-us/library/cc221408%28v=vs.95%29.aspx" rel="nofollow">依赖属性。通过执行此操作,集合会通知视图它已更改,以便视图可以自行刷新。
从
ObservableCollection
页面:在 Stack Overflow 上的回答中,这个区域有点大,但 MSDN 上有大量关于这些的信息以及这里提出的其他问题。如果在查看文档后您有一个特定的问题。
You need to use an
ObservableCollection
and Dependency Properties.By doing this the collection informs the view that it's changed so that the view can refresh itself.
From the
ObservableCollection
page:The area is a little large to go into in an answer on Stack Overflow, but there is plenty of information about these on the MSDN and other questions asked here. If, after reviewing the documentation, you have a specific question post that.