簡體   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