0

我有这个列表框代码

<ListBox x:Name="listaAdd" FontSize="30" Foreground="{StaticResource PhoneForegroundBrush}" ItemsSource="{Binding ListaMercados}"  Grid.Row="0"   UseLayoutRounding="False" Margin="0,0,0,52"  LayoutUpdated="listaAdd_LayoutUpdated" >
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid HorizontalAlignment="Stretch" Grid.Row="1" Width="480" >
                    <Grid.Background>
                        <SolidColorBrush Color="Transparent"/>
                    </Grid.Background>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="80"/>
                    </Grid.RowDefinitions>
                    <Border x:Name="borda" Tap="Borda_OnTap" Background="Transparent">
                        <ListBoxItem  x:Name="listSelected" 
                                      Grid.Row="1"
                                      IsSelected="True"
                                      VerticalAlignment="Center"  
                                      FontSize="25" 
                                      Content="{Binding Nome}"  
                                      HorizontalContentAlignment="Left" 
                                      Height="80" 
                                      Tap="ListSelected_OnTap" 
                                      FontFamily="Segoe UI" Margin="10,0,0,0" >
                            <ListBoxItem.Foreground>
                                <SolidColorBrush Color="#DEFFFFFF"/>
                            </ListBoxItem.Foreground>
                        </ListBoxItem>
                    </Border>
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu x:Name="subMenulist" Padding="0,0,0,0" FontFamily="Segoe UI" FontSize="32" Margin="0" VerticalAlignment="Center" Grid.RowSpan="1" Grid.ColumnSpan="1" TabNavigation="Local" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Background="White" >
                            <Button Grid.Column="1" 
                                        Content="excluir"  
                                        x:Name="btnExcluirDoSubMenu" 
                                        BorderThickness="0" 
                                        Margin="0,20,0,0" 
                                        Click="btnExcluirDoSubMenu_Click_1" 
                                        Foreground="#FF1A739D" 
                                        FontSize="32" 
                                        HorizontalContentAlignment="Stretch" Height="Auto" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" >
                                <Button.Background>
                                    <SolidColorBrush Color="White"/>
                                </Button.Background>
                            </Button>
                            <Button Grid.Column="1" 
                                        Content="compartilhar" 
                                        Margin="0,-20,0,0" 
                                        x:Name="btnShare" 
                                        BorderThickness="0"
                                        Click="btnShare_Click_1" 
                                        Foreground="#FF1A739D" 
                                        FontSize="32" 
                                        HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Background="White"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

我的列表框数据来自投标项目源,这是我的问题

对于每个新行(列表框),我需要在两种颜色之间更改背景颜色示例:第一行:蓝色第二行:红色第三行:蓝色第四行:红色。. . 如果我无法访问标签内的项目,我该如何更改背景颜色????

4

1 回答 1

0

您可以使用相同的数据绑定原则将列表框项模板中每个项目的背景属性绑定到颜色。

于 2012-12-09T09:48:44.320 回答