Silverlight 列表框:绑定未更新
我有一个包含多个步骤的向导控件。不可见的控件将从可视化树中删除。我在一个页面上有一个 ListBox
,它绑定到 ObservableCollection
。当在一个页面上的 ListBox
和另一页面上的 ListBox
(具有相同的 ItemsSource
)中添加或删除项目时,其他页面没有更新。我希望这足够清楚地解释我的问题。
当页面再次添加到可视化树时,如何更新此绑定?
I have a Wizard control that has multiple steps. Controls that are not visible get removed from the visual tree. I have a ListBox
on one page, that binds to an ObservableCollection<T>
. When items get added or removed to that ListBox
on one page, the ListBox
on another page (with the same ItemsSource
), the binding on the other page does not get updated. I hope this explains my problem clearly enough.
How do I get this binding to update when the page gets added to the visual tree again ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法重现你的问题。我能够从可视化树中删除 ListBox,将对象添加到 ObservableCollection,当我将其添加到可视化树时,项目实际上会更新。
尝试通过设置“折叠”的可见性来解决您的问题,而不是从可视树中删除。
I cannot reproduce your problem. I was able to remove a ListBox from the visual tree, add objects to the ObservableCollection, and when I add it to the visual tree, items are actually updated.
Try working around your problem by setting visibility to Collapsed rather than removing from Visual Tree.