无法将我的列表视图连接到搜索栏,我缺少什么?

时间:2015-12-09 19:52:28

标签: c# listview xamarin

我已经用我的数据库创建了一个列表视图(使用数据库解析),它完全正常。这些项目显示在我的列表视图中,但是当我向其插入搜索栏并尝试将它们连接在一起时,搜索栏似乎没有找到带有项目的列表(我有它在那里我可以在之间过滤列表)。有谁知道我的代码可能出现什么问题?

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;}

            }


   }


}

0 个答案:

没有答案