Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';t将我的listview连接到搜索栏,我缺少什么?_C#_Listview_Xamarin - Fatal编程技术网

C# Can';t将我的listview连接到搜索栏,我缺少什么?

C# Can';t将我的listview连接到搜索栏,我缺少什么?,c#,listview,xamarin,C#,Listview,Xamarin,我已经用我的数据库创建了一个列表视图(使用数据库解析),它工作得非常好。这些项目显示在我的列表视图中,但当我在其中插入搜索栏并尝试将它们连接在一起时,搜索栏似乎找不到包含这些项目的列表(我将其放在那里,以便在列表中的项目之间进行筛选)。有人知道我的代码有什么问题吗 using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using

我已经用我的数据库创建了一个列表视图(使用数据库解析),它工作得非常好。这些项目显示在我的列表视图中,但当我在其中插入搜索栏并尝试将它们连接在一起时,搜索栏似乎找不到包含这些项目的列表(我将其放在那里,以便在列表中的项目之间进行筛选)。有人知道我的代码有什么问题吗

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;

namespace ListCode
{
        public partial class StartPage : ContentPage
        {
                List<createSomething> ourPitems = new List<createSomething>();


            public StartPage ()
            {
                    InitializeComponent ();
                    sbSearch.TextChanged += (sender2, e2) => FilterContacts(sbSearch.Text);
                    sbSearch.SearchButtonPressed += (sender2, e2) => FilterContacts(sbSearch.Text);

            }

            private  void FilterContacts (string filter)
            {
                    EmployeeList.BeginRefresh ();

                    if (string.IsNullOrWhiteSpace (filter)) {
                            EmployeeList.ItemsSource = ourPitems;
                    } else {
                            //EmployeeList.ItemsSource = ourPitems.Contains (filter.ToLower ());
                    }

                    EmployeeList.EndRefresh ();
            }


    async void loadOurItem () //hittar våra items
            {
                    var getItems = await parseAPI.getOurMainInfo (Application.Current.Properties ["sessionToken"].ToString ());

                    EmployeeList.ItemsSource = null;
                    ourPitems = new List<createSomething> ();

                    foreach (var currentItem in getItems["results"])
                    {
                            ourPitems.Add (new createSomething ()
                            {
                                    info1 = currentItem ["listName"].ToString (),
                                    info2 = currentItem ["objectId"].ToString (),
                            });    
                    }
               EmployeeList.ItemsSource = ourPitems;
            }




public class createSomething

            {

                    public string info1 {get; set;}
                    public string info2 {get; set;}

            }


   }


}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
运用系统反思;
使用系统文本;
使用System.Threading.Tasks;
使用Xamarin.Forms;
名称空间列表代码
{
公共部分类起始页:ContentPage
{
List ourPitems=新列表();
公共起始页()
{
初始化组件();
sbSearch.TextChanged+=(发送者2,e2)=>FilterContacts(sbSearch.Text);
sbSearch.SearchButtonPressed+=(发送者2,e2)=>FilterContacts(sbSearch.Text);
}
专用void过滤器触点(字符串过滤器)
{
EmployeeList.BeginRefresh();
if(string.IsNullOrWhiteSpace(过滤器)){
EmployeeList.ItemsSource=ourPitems;
}否则{
//EmployeeList.ItemsSource=ourPitems.Contains(filter.ToLower());
}
EmployeeList.EndRefresh();
}
异步void loadOurItem()//hittar våra项目
{
var getItems=await parseAPI.getourmainfo(Application.Current.Properties[“sessionToken”].ToString());
EmployeeList.ItemsSource=null;
ourPitems=新列表();
foreach(getItems[“结果”]中的var currentItem)
{
添加(新建createSomething()
{
info1=currentItem[“listName”]。ToString(),
info2=currentItem[“objectId”]。ToString(),
});    
}
EmployeeList.ItemsSource=ourPitems;
}
公共类创建一些东西
{
公共字符串info1{get;set;}
公共字符串info2{get;set;}
}
}
}

请花时间将代码的相关部分粘贴到项目中,并正确设置格式。我第一次在这里发布一些东西时,不鼓励链接到非现场资源。我只是在直接复制代码时出错了。你没有调用loadOurItem(),所以你的列表将永远不会包含数据。该死,我遗漏了:(哈哈,我也有这个,问题不是数据,因为它在那里并且可以工作,问题是搜索栏没有与数据连接;受保护的覆盖void OnAppearing(){if(Application.Current.Properties.ContainsKey(“userId”)==false){Navigation.PushModalAsync(new LoginPage());}否则{loadOurItem();}}正在激发FilterItems()吗?您尝试过在调试器中单步执行它吗?