我在xaml中写了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#中的颜色吗?
答案 0 :(得分:3)
您可以使用画笔设置背景颜色:
var item = ListBox_Main.Items[0] as ListBoxItem ;
item.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 0));