Change textColor in list view item programmatically

后端 未结 3 1674
后悔当初
后悔当初 2021-01-29 13:40

I want to do something like this:

 textLabel_inCell.TextColor = Color.Black;

but Visual Studio shows an error:

\"textLabel_inCell doesn

相关标签:
3条回答
  • 2021-01-29 14:14

    In case of changing Xaml values programmatically either use Converters or Triggers .

    0 讨论(0)
  • 2021-01-29 14:16

    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,

    and here you the code:

        private void button1_Click(object sender, EventArgs e)
        {
            listView1.Items[2].BackColor = Color.Red;
        }
    
    0 讨论(0)
  • 2021-01-29 14:17

    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

    0 讨论(0)
提交回复
热议问题