我怎么能在一个页面上有不同的列表视图,这取决于您点击previous页是什么? [英] How can I have different listviews on one page depending on what you clicked on the previous page?
问题描述
当用户点击1或2,你会得到被推到了同一个页面,但我希望它是一个独特的列表中为每个类别点击该页面。所以,当你点击 Clickthis1
你会得到一个ListView仅 Clickthis1
的人可以访问,如果你点击 Clickthis2
如果你点击你会得到唯一可见的列表 Clickthis2
。
无效Clickthis1(对象发件人,EventArgs参数)
{
VAR类别名称=新的起始页(); CategoryName.TheCategoryName(比阿特丽斯/ *此处列表* /?); Navigation.PushAsync(类别名称);
}无效Clickthis2(对象发件人,EventArgs参数)
{
VAR类别名称=新的起始页(); CategoryName.TheCategoryName(安娜,/ *此处列表* /?);
Navigation.PushAsync(类别名称);
}
而这正是该信息被推到页面中,并在那里我有名单。我不知道我应该如何着手然而
列表< createSomething> ourPitems =新的List< createSomething>();
公共起始页()
{
的InitializeComponent();
}公共类createSomething
{
公共字符串ourUsername {搞定;组;}
}
公共无效TheCategoryName(字符串pHeader,/ *新添加到列表中位置??? * /)
{ personHeader.Text = pHeader;}保护覆盖无效OnAppearing(){
getItems(); }异步无效getItems()
{
VAR getItems =等待parseAPI.myInfo(Application.Current.Properties
[sessionToken]的ToString());
EmployeeList.ItemsSource = NULL;ourPitems =新的List< createSomething> ();的foreach(在getItems VAR CURRENTITEM [成果])
{
ourPitems.Add(新createSomething()
{ourUsername = CURRENTITEM [YOURNAME]。的ToString()
});}EmployeeList.ItemsSource = ourPitems;}
如果您选择使用公共属性,而不是超载你的构造:
在您调用页面(?起始页),通过在类别名称:
无效Clickthis1(对象发件人,EventArgs参数)
{
起始页=新的起始页();
startPage.CategoryName =类别名称;
Navigation.PushAsync(起始页));
}
然后在你的第二个页面(我称之为末页)
类末页:ContentPage
{
公共末页()
{
getItems();
} 私人字符串类别名称;
公共字符串TheCategoryName
{
{返回类别名称; }
集合{类别名称=值; }
}
然后使用类别列表中的建设方式:
异步无效getItems()
{
变种项=等待parseAPI.myInfo(Application.Current.Properties [类别名称]的ToString()); ...
}
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 Clickthis1
you'll get a ListView only Clickthis1
people can access and if you click on Clickthis2
you'll get a list only visible if you clicked 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);
}
And this is the page where the info gets pushed into and where I have the list. I am not sure how I should proceed however.
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;
}
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 ());
...
}
这篇关于我怎么能在一个页面上有不同的列表视图,这取决于您点击previous页是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!