Silverlight 3 - 过滤可观察的集合
有没有一种方法可以过滤/排序可观察的集合并仍然保留通知?
我环顾四周,发现 CollectionViewSource 可以根据需要对集合进行过滤和排序,但是当过滤器依赖的 items 属性在源集合中发生更改时,它不会刷新过滤器。
基本上我需要原始集合的视图,当视图中项目的属性更改时,它会更新源,当源更改时,它会更新视图。 silverlight 3中有提供此功能的类吗?
Is there a way to filter/sort an observable collection and still keep the notifications?
I have looked around and I found CollectionViewSource which filters and sorts the collection as I require but when the an items property in which the filter relies changes at the source collection it does not refresh the filter.
Basically i require a view of the original collection that when a property of an item in the view changes it updates the source and when the source changes it updates the view. Is there any class that provides this functionality in silverlight 3?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ObservableCollection 与 TwoWay 绑定不起作用吗?您能否用一些代码来详细说明您的示例,以更详细地显示问题?
Does ObservableCollection with TwoWay binding not work? Can you elaborate your example with some code to show the issue in more detail?
我建议使用 Bindable.Linq 库,它已经有一段时间没有更新了,并且有一个Union 运算符的错误。但对于 linq 风格的过滤器来说它效果很好。
这是一个简单的例子,假设这是在 silverlight 用户控件的代码隐藏中,其中有一个名为 people 的列表框:
如果你这样做,steve 应该出现在列表中。我发现这个库非常有用,如果您从 codeplex 下载示例项目,它会显示更高级的示例。
希望这有帮助。
还有其他几个类似的项目
I would suggest using the Bindable.Linq library, it hasn't been updated for a while and there is a bug with the Union operator. But for linq style filters it works great.
heres a quick example, assuming this is in the codebehind of a silverlight user control with a listbox named people:
if you do this steve should show up on the list. I have found this library very useful and if you download the sample projects from codeplex it shows more advanced examples.
Hope this helps.
There are several other similar projects