的情况是,我有一个列表,在它的一些HubTile(S),有没有什么办法可以取决于什么是写在一个TextBox过滤列表框?如何过滤列表框
文本框我的代码...
private void textBoxSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
}
}
感谢所有帮助感激!
的情况是,我有一个列表,在它的一些HubTile(S),有没有什么办法可以取决于什么是写在一个TextBox过滤列表框?如何过滤列表框
文本框我的代码...
private void textBoxSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
}
}
感谢所有帮助感激!
当然,只储存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));
}
}
对于这种功能更好使用CollectionViewSource。 – Mahantesh