Click here to Skip to main content
15,883,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello... i have a WPF project that uses the ado.net entity framework 4.0 with visual studios 2010. i need to filter a listbox based on the input of multiple checkboxes. i have created an entity data model and a observable collection. the project loads correctly. the problem is i can not find anything on filtering a listbox based on checkboxes. here is what i have so far:
VB
Imports System.Data.Objects

Public Class SearchMe

    Private db As New CraftingProjectsEntities
    Private ProjectsData As ProjectsCollection

    Private ProjectViewSource As CollectionViewSource
    Private WithEvents ProjectView As ListCollectionView

    Private Sub SearchMe_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        Dim query = From p In db.Projects
                    Select p

        Me.ProjectsData = New ProjectsCollection(query, db)
        Me.ProjectViewSource = CType(Me.FindResource("ProjectViewSource"), CollectionViewSource)
        Me.ProjectView = CType(Me.ProjectViewSource.View, ListCollectionView)
        MyLists.ItemsSource = ProjectsData
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click

        Dim query = (From p In db.Projects
                    Join c In db.Colorings On p.ProjectID Equals c.ProjectID
                    Join s In db.Specials On p.ProjectID Equals s.ProjectID
                    Select p).ToList()


        Me.ProjectsData = New ProjectsCollection(query.ToList(), db)
        MyLists.ItemsSource = ProjectsData
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
        MyLists.ItemsSource = Nothing
    End Sub

End Class

ok so my ProjectCollection is as ObservableCollection (of Project). i know collectionviews have built in filters. i'm just not sure how i would write the query.
thanks for any and all help. i don't know if this is possible but i have to try...
Posted
Updated 10-Dec-12 17:01pm
v3
Comments
Programm3r 12-Dec-12 6:02am    
Hi - please have a look at the following: http://stackoverflow.com/questions/10887200/multiple-filters-not-working-in-datagrid-wpf
ajk825 13-Dec-12 11:31am    
Hi Programm3r,
Ok I looked at it and I have a question. They use a GroupFilter class and I can not find anything about it anywhere... Is it part of an assembly I need to include? I searched the MSDN library and could not find a lot about it, and the info they did provide was above my level of understanding right now. Any suggestions or is it not really needed?
Programm3r 14-Dec-12 1:03am    
I suspect that GroupFilter is a custom class that they wrote.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900