Reputation: 5848
I have a ListBox
written in xaml:
<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>
We can see the background color is #19000000
, can we change the color in C#?
Upvotes: 2
Views: 1721
Reputation: 38079
You can set the background color using a brush:
var item = ListBox_Main.Items[0] as ListBoxItem ;
item.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 0));
Upvotes: 3