繁体   English   中英

如何对一个以上项目进行排序? 我只能用1个项目对列表进行排序

[英]How do I sort a list with more than 1 item? I can only get it to sort the list with 1 item

代码看起来像这样,正如我在标题中提到的那样,该代码有效,但仅包含1个项目,但我希望它搜索包含其他项目的列表。

这是我的功能代码(1个名为irl1的项目):

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

    if (string.IsNullOrWhiteSpace(filter)) {
        System.Diagnostics.Debug.WriteLine("if1");
        EmployeeList.ItemsSource = ourPitems;
    } else {
        System.Diagnostics.Debug.WriteLine("else2");
        EmployeeList.ItemsSource = ourPitems.Where(x => x.irl1.ToLower ().Contains (filter.ToLower ()));
    }

    EmployeeList.EndRefresh ();
}

我想做的事不起作用:

EmployeeList.ItemsSource = 
    ourPitems.Where(
        x => x.ourMadeUpNationality.ToLower(), 
        oem => oem.irl1.ToLower().Contains(filter.ToLower())
    );

当我使用它时,我尝试将列表向上拖动以刷新列表,但是当我在列表中搜索列表时,列表一直保持加载状态。 我试图做的是这个,但是似乎没有用。

public StartPage()
{
    InitializeComponent();

    //add the refresh function here.

    EmployeeList.BeginRefresh();
    // this is for the search list.
    sbSearch.TextChanged += (sender2, e2) => FilterContacts(sbSearch.Text);
    // this is for the search list.
    sbSearch.SearchButtonPressed += (sender2, e2) => FilterContacts(sbSearch.Text);

    EmployeeList.EndRefresh();
}

EmployeeList.ItemsSource = ourPitems.Where(tk => tk.irl1.ToLower()。Contains(filter.ToLower())&& tk.ourMadeUpNationality ==“ Test1”);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM