每当用户在文本框中输入新查询时,我都会在listview中使用listview和textbox进行搜索,是否有更好的方法呢?
private void txtEditSearch_TextChanged(object sender, TextChangedEventArgs e)
{
if (txtEditSearch.Text != string.Empty)
{
var query = GetAllSchoolsAsync(txtEditSearch.Text);
query.Wait();
List<DataClass.Tables.School> data = query.Result;
if (data.Any())
dgv.ItemsSource = data;
}
else
getSchool();
}
我需要这样的东西:
var basedata = dgv.Itemsource;
dgv.ItemSource = basedata.where(x=>x.Name == txtEditSearch.Text).Select(x=>x);
相关分类