I want to do something like this:

 textLabel_inCell.TextColor = Color.Black;

but Visual Studio shows an error:

"textLabel_inCell doesn't exist in the current context!"

How can I change text color of listView item programmatically? Please help.... Thanks everyone!

2 Answers

0
Ivan Ičin On

Yes, textLabel really doesn't exist as there is no single textLabel but rather many of them in the ListView.

In general this is done with data binding: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/xaml-basics/data-binding-basics#bindings-and-collections

-1
Community On

Simply, you can try this:

listView1.Items[0].SubItems[0].BackColor= Color.Violet;

Just do your own customization stuff for item index (0) as your need.

I hope this can help you bro ^_^

* More Clarifying * I meant this brothers,

enter image description here

and here you the code:

    private void button1_Click(object sender, EventArgs e)
    {
        listView1.Items[2].BackColor = Color.Red;
    }