请使用复选框帮助过滤collectionviews [英] please help filtering collectionviews using checkboxes

查看:68
本文介绍了请使用复选框帮助过滤collectionviews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以这是我的问题.我是wpf的新手.使用实体框架4.0.我有9个collectionviews(我目前遗漏了其中3个)

其中5个绑定到相同的StaticResource-``RcViewSource'',但是它们具有不同的路径,这些路径导致主collectionview中的不同表.
我需要能够通过其他5个视图对主collectionview进行排序/过滤,这些都是复选框.我知道我需要想出某种方法来处理已检查"事件,但我没有任何线索,这让我发疯.到目前为止,我已经想出了:

OK so here''s my problem. I''m new to wpf. using entity framework 4.0. i have 9 collectionviews (I''m currently leaving out 3 of them)

5 of them are bound to the same StaticResource- ''RcViewSource'' , however they have different paths leading to different tables within the main collectionview.
I need to be able to sort/filter the main collectionview by 5 of the other views, which are nothing but checkboxes. I know I need to come up with some kind of method to handle the "ischecked" event but I have no clue and it''s driving me insane.So far I''ve come up with:

Private Sub FilterCourses(sender As Object, e As FilterEventArgs)
    Dim c As CoursesTbl = TryCast(e.Item, CoursesTbl)
    If (c Is Nothing) OrElse c.Appetizers = False OrElse c.BreadsRolls = False OrElse c.Desserts = False OrElse c.Entrees = False OrElse c.SaucesGravies = False OrElse c.SideDishes = False OrElse c.SoupSalad = False Then
        e.Accepted = False
    Else
        e.Accepted = True
    End If
End Sub



但我不确定这是否正确...它只能处理其他视图之一.我还有4个.如何合并查询? Lambda表达式?
请有人帮我,我已经在这1个特定问题上进行了3个月以上的工作,我的大脑不知所措.

任何和所有建议,我可以阅读的帖子,教程视频都是很棒的....实际上使用复选框作为数据过滤器的示例(也许有2个进入不同的表...)也将很棒!我将不胜感激...

谢谢.



but I''m not sure if this is right... it only handles 1 of the other views. I still have 4 more. How do i combine the queries? Lambda Expressions?
Please someone help me I''ve been working on this 1 particular problem for over 3 months now and my brains fried.

Any and all suggestions, posts I could read, tutorial videos would be fantastic....Examples actually using checkboxes as data filters (maybe 2 going to different tables...) would be wonderful also! I would be beyond grateful...

Thanks.

推荐答案

这里有两点,首先,您可以只用Linq来完成这项工作,而我猜这将是最简单的事情. >
您也可以使用CollectionViewSource来归档数据.您可以使用实现谓词的自定义函数来执行此操作,也可以向该谓词发送多个参数.


我认为您应该暂时忘记贝丝·马西(Beth Massi),而去找这位女士:
http://bea.stollnitz.com/blog/?p=31 [ http://bea.stollnitz.com/blog/?p=387 [ http://bea.stollnitz.com/blog/?p=411 [ http://drc.ideablade.com/xwiki/bin/view/Documentation/predicatebuilder-methods [ ^ ]
[/Edit]
There are a couple of point here, first you could just Linq to do this job, and Ill guess that would be the simplest thing.

You could also use a CollectionViewSource to filer the data. You could do this with a custom function that implements Predicate of, you could send in multiple arguments to this predicate.


I think you should forget about Beth Massi for a while, and rather go to this lady:
http://bea.stollnitz.com/blog/?p=31[^]
http://bea.stollnitz.com/blog/?p=387[^]
http://bea.stollnitz.com/blog/?p=411[^]

She has some excellent blog post about the issues you are deling with. UInfortunatly she does writ in C# but you should be able to pick up the code :)

Otherwise you could use Linq with predicatebuilder:
http://drc.ideablade.com/xwiki/bin/view/Documentation/predicatebuilder-methods[^]
[/Edit]


这篇关于请使用复选框帮助过滤collectionviews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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