首先我在這裏和網上搜索,我發現很多很多解決方案如何在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。