首先我在这里和网上搜索,我发现很多很多解决方案如何在WPF中的列表框中更改所选项目的背景颜色,但不知道如何在Windows应用商店中做到这一点。这个框架是litte不同我不能工作的任何解决方案。更改列表框中选定项目的背景颜色
我用这个:http://social.msdn.microsoft.com/Forums/windowsapps/en-US/91575930-2058-413a-99de-f3b31c74dfd9/change-itemtemplate-forground-when-listbox-is-focused?forum=winappswithcsharp在页面的末端是很好的解决方案,但他设定项teplate这样的: ItemTemplate="{StaticResource DataTemplate1}"
但我的列表已datateplate所以我不知道通过制定者或任何不同的方式如何设定的ItemTemplate风格。
我的列表框:
<ListBox x:Name="lbMenu" ItemsSource="{Binding MyDataForLunchGrid}" Tapped="lbMenzaMenu_Tapped" Style="{StaticResource ListBoxStyle1}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Style" Value="{StaticResource ListBoxItemStyle1}"/>
</Style>
</ListBox.ItemContainerStyle >
<ListBox.ItemTemplate >
<DataTemplate>
<Grid>
<TextBlock Foreground="#FF19536E" x:Name="tbMenu" Text="{Binding launchItemName}"/>
<TextBlock x:Name="tbMenuNumber" Text="{Binding launchNumber}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
现在,当我按下列表框中的任何项目的有深紫色(默认)颜色和它的外观horible。