2

我正在尝试为 windows phone 8 应用程序创建一个按组排序的长列表选择器,我需要修复它的颜色,以匹配应用程序的颜色主题......我能够毫无问题地设置背景颜色,但发生的事情是禁用的字母背景没有显示为灰色,而是显示为与启用的字母相同的颜色......这是代码:

我在做什么:

<phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
<Style x:Key="AddrBookJumpListStyle" TargetType="phone:LongListSelector">
   <Setter Property="GridCellSize"  Value="113,113"/>
   <Setter Property="LayoutMode" Value="Grid" />
   <Setter Property="ItemTemplate">
      <Setter.Value>
         <DataTemplate>
            <Border **Background="#FF00a3e8"** Width="113" Height="113" Margin="6" >
               <TextBlock Text="{Binding Key}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="48" Padding="6" 
               Foreground="{Binding Converter={StaticResource ForegroundConverter}}" VerticalAlignment="Center"/>
            </Border>
         </DataTemplate>
       </Setter.Value>
    </Setter>
</Style>

什么会将禁用的项目显示为灰色,但将背景颜色绑定到手机的主题:

<phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
<phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
    <Style x:Key="AddrBookJumpListStyle" TargetType="phone:LongListSelector">
       <Setter Property="GridCellSize"  Value="113,113"/>
       <Setter Property="LayoutMode" Value="Grid" />
       <Setter Property="ItemTemplate">
          <Setter.Value>
             <DataTemplate>
                <Border **Background="{Binding Converter={StaticResource BackgroundConverter}}"** Width="113" Height="113" Margin="6" >
                   <TextBlock Text="{Binding Key}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="48" Padding="6" 
                   Foreground="{Binding Converter={StaticResource ForegroundConverter}}" VerticalAlignment="Center"/>
                </Border>
             </DataTemplate>
           </Setter.Value>
        </Setter>
    </Style>
4

1 回答 1

3

您应该将EnabledDisabled属性添加到JumpListItemBackgroundConverter. 像这样:

<phone:JumpListItemBackgroundConverter
    x:Key="BackgroundConverter"
    Enabled="YellowGreen"
    Disabled="DarkGreen" />

如果您只想要禁用项目的标准灰色,只需忽略该Disabled属性。

于 2014-04-23T11:49:09.007 回答