【问题标题】:Change ListBox background color更改列表框背景颜色
【发布时间】:2012-10-23 19:43:08
【问题描述】:

我有一个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#中更改颜色吗?

【问题讨论】:

    标签: xaml c# colors background listbox windows-8


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-20
      • 2015-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-09
      相关资源
      最近更新 更多