0

the situation is that I have a list with some HubTile(s) in it, is there any way I can filter the ListBox depending on what is written in a TextBox?

For the text box I have the code...

private void textBoxSearch_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {

        }
    }

Thanks, all help appreciated!

4

1 回答 1

1

当然,只需将 HubTiles 列表存储在数据结构中,当用户输入搜索查询时,对该列表执行 LINQ 查询,然后重置列表。

private List<HubTiles> myTiles;    
private void textBoxSearch_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter)
    {
       myList.ItemsSource = myTiles.Where(t => t.Title.Contains(textBoxSearch.Text));
    }
}
于 2013-06-26T19:51:53.183 回答