开发者

How to change the colour of highlighted item in a listbox

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜