Je commence par WP7 et j'essaie de changer la couleur et les autres propriétés de TexBlock. Il est inclus dans Listbox et lié à une collection. Je cherche un moyen comme 'OnDataBound'. La valeur doit changer dépend de l'objet bind.Changement de couleur de Listbox sur WP7
<ListBox HorizontalAlignment="Left" Name="listBox1" ItemsSource="{Binding}" >
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{StaticResource PhoneForegroundBrush}" Width="418" BorderThickness="1" Margin="2">
<StackPanel Orientation="Vertical" >
<StackPanel Orientation="Horizontal"><TextBlock Text="Charater: "/><TextBlock Text="{Binding Path=CharacterName}" TextWrapping="Wrap" /></StackPanel>
<StackPanel Orientation="Horizontal"><TextBlock Text="Perk launched: "/><TextBlock Text="{Binding Path=CreationDate}" TextWrapping="Wrap"/></StackPanel>
<StackPanel Orientation="Horizontal"><TextBlock Text="Finished at: "/><TextBlock Text="{Binding Path=FinishedAt}" TextWrapping="Wrap"/></StackPanel>
<StackPanel Orientation="Horizontal"><TextBlock x:Name="TextBlockStatus" Text="Status: "/><TextBlock Text="{Binding Path=Status}" TextWrapping="Wrap"/></StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Depend de statut d'objet de liaison, je dois changer propery de Textblock (couleur, etc.) pourriez-vous s'il vous plaît me dire le point indiquant?
Ma liaison est ce follwing (en .cs):
this.listBox1.DataContext = this.calculatedValues;
Merci pour votre aide
À ce moment, j'utilise un convertisseur (hérite de IValueConverter) et renvoie un SolidColorBrush, que je lie sur la propriété Forecolor d'un TextBlock. Est-ce le meilleur moyen? – Xstahef