Windows phone 8.1 wp8.1带网格的listview数据模板

Windows phone 8.1 wp8.1带网格的listview数据模板,windows-phone-8.1,Windows Phone 8.1,您好,我有一个列表视图,其中包含带有项目的datatemplate Visibility=“Visible”ScrollViewer.VerticalScrollMode=“自动” Height=“{Binding ElementName=stck\u main,Path=ActualHeight}” SelectionChanged=“lst\u OutletDetails\u SelectionChanged”> 我想使用WindowsPhone8.1中的mvvm模式更改少数项目、、的颜色

您好,我有一个列表视图,其中包含带有项目的datatemplate Visibility=“Visible”ScrollViewer.VerticalScrollMode=“自动” Height=“{Binding ElementName=stck\u main,Path=ActualHeight}” SelectionChanged=“lst\u OutletDetails\u SelectionChanged”>


我想使用WindowsPhone8.1中的mvvm模式更改少数项目、、的颜色
将您的问题(问题)放在代码块之外,它现在被隐藏了。 你到底想做什么?是否要更改列表框中少数元素的背景色?更准确地描述它:)

正如我所看到的,您将
ItemBackground
属性绑定到网格
Background
,因此只需更改源集合中所需元素的
ItemBackground

                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Margin" Value="5,0,0,0" />
                        <!--<Setter Property="Background" Value="Green"/>
                        <Setter Property="Opacity" Value="0.8"/>
                        <Setter Property="Height" Value="80"/>-->
                    </Style>
                </ListBox.ItemContainerStyle>

                <ListBox.ItemTemplate>
                    <DataTemplate>


                        <StackPanel  Orientation="Horizontal" Height="100"  >
                            <Rectangle Fill="Orange" Width="5"/>
                            <Grid x:Name="grd_items_outletdetails" Background="{Binding ItemBackground}" Width="{Binding ElementName=lst_OutletDetails,Path=ActualWidth}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition ></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition ></RowDefinition>
                                    <RowDefinition ></RowDefinition>
                                    <RowDefinition ></RowDefinition>
                                </Grid.RowDefinitions>


                                <TextBlock Text="{Binding OutletName}" Margin="5,0,0,0"  Foreground="White" FontSize="22"  Grid.Row="0" />
                                <TextBlock Text="{Binding LastVisitedDate}"  VerticalAlignment="Center" Foreground="White" FontSize="18"
                                           Grid.Row="0" Margin="5,0,40,0"  HorizontalAlignment="Right" />


                                <TextBlock Text="{Binding OutletCode}" Foreground="White" Margin="5,0,0,0" FontSize="18"  HorizontalAlignment="Left" Grid.Row="1"/>

                                <StackPanel Orientation="Horizontal" Margin="5,0,20,0" Grid.Row="1"  HorizontalAlignment="Right">
                                <TextBlock Text="ISM:" Foreground="White" Margin="0,0,0,0" FontSize="18"  />
                                <TextBlock Text="{Binding ISMName}" Foreground="White" Margin="5,0,20,0" FontSize="18"  />
                                </StackPanel>

                                <TextBlock Text="{Binding Route}"  Margin="5,0,0,0" FontSize="18" Grid.Row="2" HorizontalAlignment="Left"  Foreground="White" />

                                <StackPanel Orientation="Horizontal"  Margin="5,0,20,0" Grid.Row="2"  HorizontalAlignment="Right">
                                  <TextBlock Text="Status:" Foreground="White" Margin="5,0,0,0" FontSize="18" ></TextBlock>
                                  <TextBlock Text="{Binding Status}" Foreground="White" Margin="5,0,20,0" FontSize="18"  />
                                </StackPanel>
                            </Grid>
                        </StackPanel>


                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

i want to change the colors of few items ,,, using mvvm pattern in windows phone 8.1