C# Xamarin表单列表视图搜索

C# Xamarin表单列表视图搜索,c#,json,xamarin.forms,C#,Json,Xamarin.forms,我似乎无法让它正确更新,它只显示列表的前两项 我正在从一个web API接收json数据,我只想能够在listview中搜索一个名称并显示它,我已经尝试了很多这样的例子,但似乎无法让它实际工作,我是否需要将列表封装并订阅INotify 公共列表x; 公共异步任务InitAsync() { var p=wait wc.Tag.GetAll(新字典(){ {“每页”,“100”}); x=p; productsListView.FlowItemsSource=p; } 私有无效搜索栏\u Tex

我似乎无法让它正确更新,它只显示列表的前两项

我正在从一个web API接收json数据,我只想能够在listview中搜索一个名称并显示它,我已经尝试了很多这样的例子,但似乎无法让它实际工作,我是否需要将列表封装并订阅INotify


公共列表x;
公共异步任务InitAsync()
{
var p=wait wc.Tag.GetAll(新字典(){
{“每页”,“100”});
x=p;
productsListView.FlowItemsSource=p;
}
私有无效搜索栏\u TextChanged(对象发送者,textchangedventargs e)
{
//这就是你需要搜索的全部内容
productsListView.BeginRefresh();
if(string.IsNullOrWhiteSpace(e.NewTextValue))
productsListView.ItemsSource=x;
其他的
productsListView.ItemsSource=x.Where(i=>i.name.Contains(e.NewTextValue));
productsListView.EndRefresh();
}

在您的搜索栏中,我认为您没有以正确的方式提供FlowListView的源代码。与productsListView.ItemsSource不同,它应该是:

productsListView.FlowItemsSource = x.Where(i => i.name.Contains(e.NewTextValue));

嗯,我经常这么做。是的,这是正确的,在我的例子中,我需要转换到一个列表,所以
productsListView.FlowItemsSource=x.Where(I=>I.name.Contains(e.NewTextValue)).toList()