0
Answer

Problem to display listBox.Items.Add in ListBox

Hello,

I've in my C# class:
  1. foreach (var item in horaires)
  2. {
  3. var Objet = item.Horraire.ToString();
  4. listBox.Items.Add(Objet);
  5. }
And in my XAML:
<ListBox x:Name="listBox" Grid.Row="1"/>

My data are great, but I would custom my ListBox with:
  1. <ListBox.ItemTemplate>
  2.         <DataTemplate>
  3.                 <Border BorderBrush="White" Margin="0" BorderThickness="0,0,0,0.5">
  4.                         <StackPanel Orientation="Horizontal" Margin="0,5,0,5" VerticalAlignment="Top">
  5.                                 <TextBlock Text="{Binding item}"
  6. Name="item"

  7. FontSize="36"

  8. VerticalAlignment="Top"

  9. TextAlignment="Left"

  10. TextWrapping="Wrap"

  11. Width="340"/>

  12. </StackPanel>

  13. </Border>

  14. </DataTemplate>

  15. </ListBox.ItemTemplate>
But With, my data don't show. So, How to display my data with this model?
I would like make listBox.Items.Add(Objet); in my TextBlock Name="item"

Thanks for your helps.
Valentin