I have a listview same as styling example http://https//docs.telerik.com/devtools/xamarin/controls/listview/features/listview-features-styling
But i need to change selected item background color to white and Text color to something else(let's say Red).
Background color changed but not Text color. What am i doing wrong or any fix for this ?
5 Answers, 1 is accepted
You are probably using a custom ItemTemplate for your RadListView which results in the behavior you are observing. When using custom templates, and respectively an element of your choice to display information regarding your items, the foreground color of this element is not automatically updated. You can set up additional logic to style it when it is selected. For example:
This will return different color based on the IsSelected property of your business object(you can add such):
And you can update the IsSelected item through the SelectionChanged event of the RadListView:
Another approach is to use a custom ItemTemplateSelector and return different DataTemplates by checking what is the selected item of the RadListView.I have attached a sample that shows the second approach for your reference.
Thank you very much for your answer. This answer answered another question in my mind, But i am not referring custom item template in this question. it is about "<telerikListView:ListViewTextCell />".
Have more questions,
- Text in this cell is not expanding its cell to text length automatically or wrapping
- Can not change text color
I 'll post sample code i am using
Thank you for the additional information. When testing with the ListViewTextCell, the behavior seems correct in Android and UWP. However, in iOS indeed there is a big spacing between the items and their width is equal. Still, using a ListViewTemplateCell instead of a ListViewTextCell seems to achieve the desired behavior. Please have a look at the attached sample. You can use the template cell in combination with one of the approaches I have provided in my original reply.
Have a great rest of the week.
Now its working , problem was in item template. i added TextColor="White" in there. that should done on 'ItemStyle'
But text wrapping is not working, in both android and ios, if i turn phone landscape text cells expanding nad showing content, not in portrait mode.
Could you use the sample I have provided to show the exact behavior as I am not sure I understand the issue you are facing?