Pregunta

I'm trying to create a group sorted long list selector for a windows phone 8 app and I need it's color to be fixed, to mach the app's color theme... I'm being able to set the background color with no problem, but what is happening is that the disabled letters background does not appear grayed-out, instead they are appear with the same color as the enabled ones... This is the code:

What I'm doing:

<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>

What will show the disabled items grayed-out, but bind the background color to the phone's theme:

<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>
¿Fue útil?

Solución

You should add the Enabled and Disabled properties to the JumpListItemBackgroundConverter. Like so:

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

If you just want the standard gray-ish color for the disabled items, just leave out the Disabledproperty.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top