Inside my Windows Phone 7 application I have a list box with a list of 50 authors. I want to display the first 5 items of my list box with a white foreground (or black depending of theme), and the rest of them in gray.
<ListBox x:Name="AuthorsListBox" ItemsSource="{Binding}" Grid.Row="1"    >
                    <ListBox.ItemTemplate>
                开发者_开发技巧        <DataTemplate>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Name}" 
                                  Name="{Binding Id}" Width="320" Height="70"
                                  TextWrapping="Wrap" TextAlignment="Left" 
                                  Margin="0,0,0,10"  FontSize="30" 
                                  ManipulationCompleted="Author_ManipulationCompleted"/>                                 
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
</ListBox>
Here is my C# code:
AuthorsListBox.ItemsSource = AuthorsList.OrderBy(a => a.Name);
Bind the Foreground property of the Textblock to the desired colour. Or to an indictor and use a converter to select the colour based on the indicator.
I would add an "Onitemdatabound" to the listbox and then set the colour in that method
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论