开发者

How to change the colour of highlighted item in a listbox

开发者 https://www.devze.com 2023-02-23 17:46 出处:网络
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

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

精彩评论

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