Click here to Skip to main content
11,649,522 members (76,573 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB WPF LINQ Entities
hello... i have a WPF project that uses the 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:
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 10-Dec-12 4:29am
Edited 10-Dec-12 17:01pm
Programm3r at 12-Dec-12 6:02am
Hi - please have a look at the following:
ajk825 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 354
1 F-ES Sitecore 344
2 Kornfeld Eliyahu Peter 319
3 CPallini 290
4 Maciej Los 269
0 OriginalGriff 1,577
1 Sergey Alexandrovich Kryukov 1,087
2 CPallini 1,015
3 DamithSL 996
4 994

Advertise | Privacy | Mobile
Web01 | 2.8.150804.4 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100