In the code-behind of the parent page, how do we say,
foreach(label in the ListView)
{
if(label.Text == "something")
{
//do some formatting
}
}
I think this should be in the override of OnAppearing but I'm not sure of the syntax.
thanks
UPDATE: In response to comments, the ListView has 2 labels, I want to say, if label1 = "x", do specific formatting on label2.
Hope that's a bit clearer
There is a property in ListView
named TemplatedItems
that return a ViewCell
and we can get from this ViewCell all views that we have (if you use template may it will be a little bit different).
foreach (ViewCell myViewCell in mylist.TemplatedItems)
{
Label myLabel = (Label) myViewCell.View;
if (myLabel.Text == "smth")
{
//do some formatting
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.