簡體   English   中英

如何更改列表框中突出顯示的項目的顏色

[英]How to change the colour of highlighted item in a listbox

我正在嘗試更改ListBox所選項目的顏色。 它似乎總是淡藍色的。 我嘗試更改選定項目時更改該項目的前景色,但沒有效果。 我正在使用WP7。

編輯:我想更改所選項目的文本顏色。

嘗試這個:

選項1:

ListBoxItem lbi1 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromIndex(0));
lbi1.Foreground = new SolidColorBrush(Color.FromArgb(100, 45, 23, 45));

選項2:

ListBoxItem lbi2 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromItem(listBox.SelectedItem));

lbi2.Foreground= new SolidColorBrush(Colors.Red);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM