views:

171

answers:

0

I have a listbox the item template of which is a listbox. I am trying to set the "Foreground" property of the internal listbox to be the same as that of the main listbox. This is failing. Following is the code snippet. In here Foreground="{TemplateBinding Foreground}" has no effect.

<ListBox x:Name="GroupListBox" Grid.Column="1" Grid.Row="1" Style="{StaticResource ListBoxStyle1}" Visibility="Collapsed"
             BorderBrush="Transparent" Background="Transparent" Foreground="{Binding WebForeground}">
        <ListBox.ItemTemplate>
            <DataTemplate x:Name="test">
                <StackPanel Orientation="Horizontal" >
                    <!--<TextBlock Text="{Binding Rank}" FontFamily="Arial" FontSize="13" TextDecorations="Underline" TextWrapping="Wrap" Width="115" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,15,0,0"/>-->
                    <ListBox x:Name="SubGroupListBox" ItemsSource="{Binding InnerList }" ItemTemplate="{StaticResource ItemTemplateKey1}" 
                             ItemsPanel="{StaticResource ItemsPanelKey}" Style="{StaticResource ListBoxStyle1}" 
                             BorderBrush="Transparent" Background="Transparent" Foreground="{TemplateBinding Foreground}">                            
                    </ListBox>
             </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>