开发者

Silverlight 4 PagedCollectionView with Multiple Filters [duplicate]

This question already has answers here: How do I dynamically construct a predicate method from an exp开发者_运维知识库ression tree? (3 answers) Closed 2 years ago.

I'm new to Silverlight 4 and the PagedCollectionView. I know it's possible to add a filter to a PCV such as

pvc.Filter = new Predicate(FilterProjectId);

Where pvc is a populated PagedCollectionView.

What I need to do is stack multiple filters to a PCV as I've got a search screen with about 6 fields on it and a DataGrid that's bound to the PCV. Depending on what ComboBoxes are selected, when a search button is pressed, I need to filter the PCV results based on those selections.

I can only seem to get it to take the last filter set. Can anyone provide me with information on how to stack them?

Thanks


The Filter property is simply a delegate to a function that takes an object and returns a boolean. That function can be as simple or as complex as you choose to write.

Sounds to me that you just need one function contain a series of if blocks that compares the object with each of your 6 fields as necessary then returns the result.

The point is there is no "set of filters" that you can "stack" you just write a filter function that does all you need it to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜