用户单击 1 或 2 的页面将被推送到同一页面,但我希望它成为每个单击类别的唯一列表。所以,当你点击Clickthis1
你只会得到一个ListViewClickthis1
人们可以访问,如果您点击Clickthis2
仅当您单击时您才会看到一个列表Clickthis2
.
void Clickthis1 (object sender, EventArgs args)
{
var CategoryName = new StartPage();
CategoryName.TheCategoryName ("Beatrice", /* the list here?*/);
Navigation.PushAsync (CategoryName);
}
void Clickthis2 (object sender, EventArgs args)
{
var CategoryName = new StartPage();
CategoryName.TheCategoryName ("Anna", /* the list here?*/);
Navigation.PushAsync(CategoryName);
}
这是信息被推送到的页面,也是我拥有列表的页面。但我不确定应该如何进行。
List<createSomething> ourPitems = new List<createSomething>();
public StartPage ()
{
InitializeComponent ();
}
public class createSomething
{
public string ourUsername {get; set;}
}
public void TheCategoryName (String pHeader, /*New list added here???*/)
{
personHeader.Text = pHeader;
}
protected override void OnAppearing(){
getItems (); }
async void getItems ()
{
var getItems = await parseAPI.myInfo (Application.Current.Properties
["sessionToken"].ToString ());
EmployeeList.ItemsSource = null;
ourPitems = new List<createSomething> ();
foreach (var currentItem in getItems["results"])
{
ourPitems.Add (new createSomething ()
{
ourUsername = currentItem ["YourName"].ToString (),
});}
EmployeeList.ItemsSource = ourPitems;
}
如果您选择使用公共属性而不是重载构造函数:
在您的调用页面(StartPage?)中,传入类别名称:
void Clickthis1 (object sender, EventArgs args)
{
startPage= new StartPage();
startPage.CategoryName = categoryName;
Navigation.PushAsync (startPage));
}
然后在第二页(我将其称为 ListPage)
class ListPage : ContentPage
{
public ListPage()
{
getItems ();
}
private string categoryName;
public string TheCategoryName
{
get { return categoryName; }
set { categoryName= value; }
}
然后在列表构建方法中使用类别:
async void getItems ()
{
var items = await parseAPI.myInfo (Application.Current.Properties[categoryName].ToString ());
...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)