title: Filling a ListBox with an ObservableCollection and display properties of selected items in StackPanel
body: <p>I'm tring to <strong>databind properties of an ObservableCollection to a ListBox</strong> (Just the Title property for example).</p>
  
  <p>By clicking on one of the ListItem (with an event ), i'd like to <strong>display all the properties of the Collection into a StackPanel</strong>. After many tries, I still don't know how can I figure it out...</p>
  
  <p>Here is my code behind :</p>
  
  <pre><code>public partial class TestListView : Window 
  {
  
      public TestListView()
      {
  
          ObservableCollection&lt;Programme&gt; pgr = new ObservableCollection&lt;Programme&gt;();
          pgr = readfile();
  
          InitializeComponent();
  
  
      }
  
      public class Programme
      {
          public String Title { get; set; }
          public String Date { get; set; }
          public String Chaine { get; set; }
  
          public Programme(String Title, String Date, String Chaine)
          {
              this.Title = Title;
              this.Date = Date;
              this.Chaine = Chaine;
          }     
      }
  </code></pre>
  
  <p>Here is my XAML :</p>
  
  <pre><code>    &lt;Window x:Class="Test.TestListView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:Test;assembly=Test"
      Title="TestListView" Height="500" Width="1000" x:Name="Window"&gt;
  
  &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
  
          &lt;ColumnDefinition Width="249*"/&gt;
          &lt;ColumnDefinition Width="743*"/&gt;
  
  
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid.RowDefinitions&gt;
  
          &lt;RowDefinition Height="20*"/&gt;
          &lt;RowDefinition Height="428*"/&gt;
          &lt;RowDefinition Height="21*"/&gt;
  
      &lt;/Grid.RowDefinitions&gt;
      &lt;ListBox Name="l1" ItemsSource="{Binding pgr}"&gt;
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel&gt;
                      &lt;TextBlock Text="{Binding Title}"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
      &lt;StackPanel Grid.Column="1" Grid.Row="1"&gt;
          &lt;TextBox Margin="343,0,0,0" x:Name="Recherche"&gt;&lt;/TextBox&gt;
          &lt;Button Height="37" Margin="669,0,0,0" &gt;&lt;/Button&gt;
          &lt;TextBlock x:Name="t1" Margin="214,0,293,0" Height="33" /&gt;
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
      &lt;/Window&gt;
  </code></pre>