Click here to Skip to main content
15,843,145 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have to create a list of students and I need to create a search bar using text box. The student details are in {studentABC}. I need to filter the students by first name and display in a list.

It's not working. What am I doing wrong?

What I have tried:

<TextBox x:Name="search_box" Margin="60,20,0,0" 
            PlaceholderText="Search first Name"
            Width="200" TextChanged="search_box_TextChanged">

the first name code is
<ListView.ItemTemplate >
   <DataTemplate x:DataType="local:studentitem" x:DefaultBindMode="TwoWay" >
      <StackPanel Orientation="Horizontal" >
         <TextBlock x:Name="fname" 
                       Width="150" Text="{Binding FirstName}"  
                       Foreground="Gray" FontSize="16"
                       Margin="20,0,10,0" />

my data ascess
public static List<StudentItem> getallstudent(Int64 Id)
//etc code..!
	SqliteDataReader query = selectCommand.ExecuteReader();
    while (query.Read())
        var e_item = new studentitem();

        e_item.ID = query.GetInt64(1);
        e_item.FirstName = query.GetString(2);
        e_item.LastName = query.GetString(3);
        e_item.DOB = query.GetString(4);
Updated 6-Dec-22 5:06am
Richard Deeming 5-Dec-22 8:01am    

You seem to have forgotten to ask a question.
Ailiseu Brigitta 5-Dec-22 8:05am    
my question is how can filter the student by student first name and display in a list
Richard Deeming 5-Dec-22 8:18am    
You haven't shown us how you're binding the list of students, nor told us what you have tried or where you are stuck.
Ailiseu Brigitta 5-Dec-22 8:23am    
List<studentitem> studentlist = DataAccess.getallstudent(studentABC);

studentListView.ItemsSource = studentlist;
Richard Deeming 5-Dec-22 8:25am    
Then you're going to need to update your custom DataAccess class - which we can't see - to allow you to search for a student.

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