I'm trying to change the colour of the selected item of my ListBox. It always seems to be a light blue. I Have tried changing the foreground colour of the item whe开发者_StackOverflown selected item is changed, this has no effect. I am using WP7 Any advice is apreciated.
EDIT: I want to change the text colour of the selected item.
Try this:
Option1:
ListBoxItem lbi1 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromIndex(0));
lbi1.Foreground = new SolidColorBrush(Color.FromArgb(100, 45, 23, 45));
Option2:
ListBoxItem lbi2 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromItem(listBox.SelectedItem));
lbi2.Foreground= new SolidColorBrush(Colors.Red);
精彩评论