Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB WPF LINQ Entities
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:
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 5:29am
ajk825555
Edited 10-Dec-12 18:01pm
v3
Comments
Programm3r at 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 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 DamithSL 270
1 OriginalGriff 184
2 BillWoodruff 170
3 Zoltán Zörgő 165
4 Sergey Alexandrovich Kryukov 125
0 OriginalGriff 7,760
1 DamithSL 5,874
2 Sergey Alexandrovich Kryukov 5,444
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2014
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