title: toolkit:ExpanderView in Listbox
body: <p>I have troubles with binding data to a Listbox to dynamically create ExpanderView.</p>
  
  <p>I have used Listboxes in my Code before, so I'm not sure if the binding is really the problem. Am I setting the contents of ExpanderView wrong?</p>
  
  <p>My Code so far in XAML:</p>
  
  <pre><code>                &lt;ListBox x:Name="Newsticker_Listbox"&gt;
                      &lt;ListBox.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;toolkit:ExpanderView Header="{Binding}" Expander="{Binding}" ItemsSource="{Binding}"
                                HeaderTemplate="{StaticResource CustomHeaderTemplate}"
                               ExpanderTemplate="{StaticResource CustomExpanderTemplate}"
                                ItemTemplate="{StaticResource CustomItemTemplate}" /&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ListBox.ItemTemplate&gt;
                  &lt;/ListBox&gt;
  </code></pre>
  
  <p>the Templates:</p>
  
  <pre><code>&lt;!--newsfeed templates--&gt;
  &lt;phone:PhoneApplicationPage.Resources&gt;
      &lt;DataTemplate x:Key="CustomHeaderTemplate"&gt;
          &lt;TextBlock Text="{Binding Title}" /&gt;
      &lt;/DataTemplate&gt;
      &lt;DataTemplate x:Key="CustomExpanderTemplate"&gt;
          &lt;Image Source="{Binding Subtitle}" /&gt;
      &lt;/DataTemplate&gt;
      &lt;DataTemplate x:Key="CustomItemTemplate"&gt;
          &lt;TextBlock Text="{Binding Title}" /&gt;
      &lt;/DataTemplate&gt;
  &lt;/phone:PhoneApplicationPage.Resources&gt;
  </code></pre>
  
  <p>I'm binding with </p>
  
  <pre><code>ObservableCollection&lt;news&gt; newslist = new ObservableCollection&lt;news&gt;();
  //populate
  Newsticker_Listbox.ItemsSource = newslist; 
  </code></pre>
  
  <p>news is a really simple object, it just stores some strings, which can be read out by news.Title, news.Subtitle etc</p>
  
  <p>I've used the example from <a href="http://www.geekchamp.com/articles/expand-and-collapse-expanderview-inside-data-bound-listbox-via-code" rel="nofollow">http://www.geekchamp.com/articles/expand-and-collapse-expanderview-inside-data-bound-listbox-via-code</a> as basic for my code, I've just simplified it for my cause (mabye too much?)</p>
  
  <p>Help is very appreciated, thank you all in advance</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This code works so far, but why does the solution with templates not work?</p>
  
  <pre><code>&lt;ListBox x:Name="Newsticker_Listbox"&gt;
                      &lt;ListBox.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;Grid&gt;
                                  &lt;Grid.RowDefinitions&gt;
                                      &lt;RowDefinition Height="auto"/&gt;
                                      &lt;RowDefinition Height="10"/&gt;
                                  &lt;/Grid.RowDefinitions&gt;
                                  &lt;Grid.ColumnDefinitions&gt;
                                  &lt;/Grid.ColumnDefinitions&gt;
                                  &lt;toolkit:ExpanderView&gt;
                                      &lt;toolkit:ExpanderView.Header&gt;
                                          &lt;TextBlock Text="{Binding Titel}" /&gt;
                                      &lt;/toolkit:ExpanderView.Header&gt;
                                      &lt;toolkit:ExpanderView.Expander&gt;
                                          &lt;TextBlock Text="{Binding Untertitel}" /&gt;
                                      &lt;/toolkit:ExpanderView.Expander&gt;
                                      &lt;toolkit:ExpanderView.Items&gt;
                                          &lt;TextBlock Text="{Binding Text}" /&gt;
                                      &lt;/toolkit:ExpanderView.Items&gt;
                                  &lt;/toolkit:ExpanderView&gt;
                              &lt;/Grid&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ListBox.ItemTemplate&gt;
                  &lt;/ListBox&gt;
  </code></pre>