只是想知道如果有一种方法可以命名列表视图并按编号分隔。
所以我想的是有一种方法可以做到这样:
void Clickthis1 (object sender, EventArgs args)
{
var thePage = new StartPage();
thePage.TheCategoryName ("Info1", StartPage.ourPitems[0]); //our listview
Navigation.PushAsync (thePage);
}
void Clickthis2 (object sender, EventArgs args)
{
var thePage = new StartPage();
thePage.TheCategoryName ("Info2", StartPage.ourPitems[1]) //listview with a diff number?
Navigation.PushAsync (thePage);
和我的列表所在的页面;
public static List<createSomething> ourPitems = new List<createSomething>(string theCategoryName);
public StartPage ()
{
InitializeComponent ();
}
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> (/* something in here then? */);
foreach (var currentItem in getItems["results"])
{
ourPitems.Add (new createSomething ()
{
ourUsername = currentItem ["YourName"].ToString (),
});}
EmployeeList.ItemsSource = ourPitems;
}
public class createSomething
{
public string ourUsername {get; set;}
}
所以这显然不起作用但是我有正确的想法&#34;我应该如何执行这个?
答案 0 :(得分:0)
让我看看如果我得到它,你有两个按钮,你想要如果用户点击一个按钮出现列表1和第二个按钮列表2 如果这是你想要的,你可以这样做:
1 - 你应该有两个清单: List MyList1 = new List MyList1(); 列表MyList2 =新列表MyList1();
2 - 在单击按钮中,更改ListView的项目源:
void OnClickButton1(对象发送者,EventArgs args) {
EmployeeList.ItemsSource = MyList1; }
void OnClickButton2(对象发送者,EventArgs args) {
EmployeeList.ItemsSource = MyList2; }