而不是为每个列表视图创建数据库。如何对类别进行排序并使列表加载不同的类别,可能是通过我的searchfilter?

时间:2015-12-25 12:53:33

标签: c# forms xamarin

void Clickthis (object sender, EventArgs args)
    {

        var name = new StartPage();

        name.CategoryName ("Info1");

        Navigation.PushAsync (name);

    }

    void Clickthis1 (object sender, EventArgs args)
    {

        var name = new StartPage();

        name.CategoryName ("Info2");

        Navigation.PushAsync (name);
    }

我现在将它推到这个功能:

    public void CategoryName (String pHeader)
    {
        productHeader.Text = pHeader;

        App.theUserCategory = pHeader;


        Application.Current.Properties ["theCategory"] = App.theUserCategory;
        Application.Current.SavePropertiesAsync ();
        System.Diagnostics.Debug.WriteLine (App.theUserCategory);
    }

所以我将“selectedname”存储在我的数据库(theCategory)中,但现在我想以某种方式对所选名称进行排序,以便根据您点击的内容,listview将只显示该selectedname中的项目。

也许我可以通过某种方式通过我的过滤器排序???

    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 ()));
            //Contains (filter.ToLower ());

        }

        EmployeeList.EndRefresh ();
    }

我的清单和数据库:

public static List<createSomething> ourPitems = new List<createSomething>();


async void loadOurItem () ¨
    {
        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 () 
            { 
                ourName = currentItem ["listName"].ToString ()
            });

        }

        EmployeeList.ItemsSource = ourPitems;
    }

0 个答案:

没有答案