Tom*_*res 1 c# windows-phone-7
我正在尝试更改ListBox所选项目的颜色.它似乎总是浅蓝色.我已经尝试在更改所选项目时更改项目的前景色,这没有任何效果.我正在使用WP7任何建议都是apreciated.
编辑:我想更改所选项目的文本颜色.
试试这个:
选项1:
ListBoxItem lbi1 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromIndex(0));
lbi1.Foreground = new SolidColorBrush(Color.FromArgb(100, 45, 23, 45));
Run Code Online (Sandbox Code Playgroud)
选项2:
ListBoxItem lbi2 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromItem(listBox.SelectedItem));
lbi2.Foreground= new SolidColorBrush(Colors.Red);
Run Code Online (Sandbox Code Playgroud)