Listview - loop through all rows

Is it possible to loop through a listview and modify element style (not the values)?

For example, if I want to change the style of the name textField:

_listView.bindItem = (element, index) =>
{
    var name = element.Q<TextField>("listview-name");

    name.value = listValues[index];
};

Now I would like to loop through all the rows and change its elements:

foreach(var row in (how to get rows of list?))
{
    if(row == somecondition)
    {
        row.name.style.color = Color.red;
    }
}

I’ve also been looking into events for this.
Is there an event that triggers when the list is rebuilt? In that case I can add a RegisterCallback for the name textfield to change it that way.

You would access them by using listView[index], however rather than accessing all the elements you can add and remove styleSheets to the list itself, like listView.styleSheets.Add(newStyleSheet) and listView.styleSheets.Remove(oldStyleSheet).

Thanks for your reply!
The problem is I don’t want to change the style of everything, just specific rows based on a condition.

I tried listView[index], but can’t get it to work. How would I get the length of the list? There is no listView.length or listView.Count. Ideally I would like to have something like this:

csharp*_ <em>*for (int i = 0; i < listView.Count; i++) { var name = listView[i].Q<TextField>("listview-name"); if(listValues[i] == condition) name.AddToClassList("textFieldRed"); }*</em> _*

Sorry, I’m using scrollview and it works fine. Listview is more complicated. If you really want to use a listview then maybe you should register the references to the elements in makeItem or bindItem.

Thanks, I registered the references in bindItem to a List, which works.

Be careful that it can break if the items are being reused, Listview seems to be appropriate to use for a large number of items.