How can I have different listviews on one page depending on what you clicked on the previous page?

后端 未结 1 597
悲哀的现实
悲哀的现实 2021-01-23 09:13

The page where the user clicks either 1 or 2 and you get pushed to the same page, but I want it to be a unique list for each category clicked. So, when you click on Clickt

相关标签:
1条回答
  • 2021-01-23 09:40

    If you choose to use public properties instead of overloading your constructor:

    In your calling page (StartPage?), pass in the Category Name:

    void Clickthis1 (object sender, EventArgs args)
    {
        startPage= new StartPage(); 
        startPage.CategoryName = categoryName;
        Navigation.PushAsync (startPage));
    }
    

    Then in your second page (which I'll call ListPage)

    class ListPage : ContentPage
    {
        public ListPage()
        {
            getItems ();
        }
    
        private string categoryName; 
        public string TheCategoryName 
        { 
            get { return categoryName; }
            set { categoryName= value; }
        }
    

    Then use the category in your list-building method:

    async void getItems () 
    {
        var items = await parseAPI.myInfo (Application.Current.Properties[categoryName].ToString ());
    
        ...
    }
    
    0 讨论(0)
提交回复
热议问题