更改ListBox背景颜色

时间:2012-11-03 08:03:06

标签: c# colors background listbox windows-8

我在中写了ListBox

<ListBox Margin="0" x:Name="ListBox_Main" Grid.Row="1" VerticalAlignment="Top" FontSize="24" SelectionChanged="ListBox_Main_SelectionChanged" Foreground="Black">
    <ListBoxItem Content="Item 1" Background="#19000000" />
    <ListBoxItem Content="Item 2" Background="#19000000" />
    <ListBoxItem Content="Item 3" Background="#19000000" />
    <ListBoxItem Content="Item 4" Background="#19000000"/>
    <ListBoxItem Content="Item 5" Background="#19000000"/>
 </ListBox>

我们可以看到背景颜色是#19000000,我们可以改变C#中的颜色吗?

1 个答案:

答案 0 :(得分:3)

您可以使用画笔设置背景颜色:

var item = ListBox_Main.Items[0] as ListBoxItem ;
item.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 0));
相关问题