Hi,
I'm creating an application that has many tables with many foreign key constraints. For example, in my case I have a student. Each student table has a foreign key relation with a parental details table and medical details table.
To make my application easy to use, I have implemented a series of different filters to help a user search through large amounts of data.
I have one listview to display the student records, and same with the parental and medical details. However, What I want to do is to search through the student records based on a set of criteria from the parental details. For example, search for a parental name. This is what Ive tried;
//Constructor; StudentList = new ObservableCollection<StudentViewModel>(GetStudents()); CollectionViewSource.GetDefaultView(StudentList).Filter = new Predicate<object>(MainFilter); private string contactNameSearch; public string ContactNameSearch { get { return contactNameSearch; } set { contactNameSearch = value; CollectionViewSource.GetDefaultView(StudentList).Refresh(); OnPropertyChanged("ContactNameSearch"); } } private bool FilterContactNameSearch(object obj) { StudentContactViewModel item = obj as StudentContactViewModel; if (item == null) return false; if (String.IsNullOrWhiteSpace(ContactNameSearch)) return true; if (ContactNameSearch.Trim().Length == 0) return true; if (item.Name1.ToLower().Contains(ContactNameSearch.ToLower())) return true; return false; } public bool MainFilter(object o) { return FilterContactNameSearch(o); // &... and more filters }
//Within the xaml;<TextBox Height="23" Name="txtContactName" Width="100" Text="{Binding ContactNameSearch, UpdateSourceTrigger=PropertyChanged}"/>
However, when I do this, the data within student table that is populated vanishes.this link illustrates this
Therefore, my question is; Am I implementing this correctly and if not, is there an alternative way of doing it?
Thanks in advance,
Greg.