title: WPF Bind a List<List<object>> to a ItemsControl which holds ItemControls as Items
body: <p>I want to show a List with items where each item contains several items.
  I tried to realize this with ItemsControls so that the ItemsControl on top is bound to the List that holds several Lists.
  The itemtemplate of the ItemsControl on top contains a Label with a Style which defines that the label should hold a textbox and a ItemsControl.
  The textbox should be bound to an property of the list and the ItemsControl should be bound to the list itself. This ItemsControl again has an textblock as itemtemplate which Text and Visibility-property is bound to properties of the Items which are in the lower list.</p>
  
  <p>The ItemsControl on top:</p>
  
  <pre class="lang-wpf prettyprint-override"><code>&lt;UserControl.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="../Styles/AlternativeAdressBoxStyle.xaml"/&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/UserControl.Resources&gt;
  &lt;Grid Margin="10,0,10,10"&gt;
      &lt;Border BorderBrush="Black"
              BorderThickness="1"&gt;
          &lt;ItemsControl ItemsSource="{Binding AlternativeAdressLabelList}"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"&gt;
              &lt;ItemsControl.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;StackPanel Orientation="Horizontal"/&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/ItemsControl.ItemsPanel&gt;
              &lt;ItemsControl.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Label Style="{StaticResource AlternativeAdressBoxStyle}"
                             DataContext="{Binding}"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ItemsControl.ItemTemplate&gt;
          &lt;/ItemsControl&gt;
      &lt;/Border&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>The Style-file:</p>
  
  <pre class="lang-wpf prettyprint-override"><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
  
  
      &lt;ResourceDictionary.MergedDictionaries&gt;
          &lt;ResourceDictionary Source="../Styles/LabelRowTextBlockStyle.xaml"/&gt;
      &lt;/ResourceDictionary.MergedDictionaries&gt;
  
      &lt;Style x:Key="AlternativeAdressBoxStyle" 
             TargetType="Label"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="Label"&gt;
                      &lt;Grid&gt;
                          &lt;Grid&gt;
                              &lt;Grid.RowDefinitions&gt;
                                  &lt;RowDefinition Height="0.1*"/&gt;
                                  &lt;RowDefinition Height="*"/&gt;
                              &lt;/Grid.RowDefinitions&gt;
                              &lt;TextBlock Grid.Row="0"
                             VerticalAlignment="Center"
                             HorizontalAlignment="Center"
                                         Text="{Binding Path=.AcountingArea}"/&gt;
                              &lt;Border Grid.Row="1"
                          Margin="20"
                          BorderBrush="Black"
                          BorderThickness="1"&gt;
                                  &lt;Grid&gt;
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition Width="*"/&gt;
                                          &lt;ColumnDefinition Width="Auto"/&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
                                      &lt;Grid.RowDefinitions&gt;
                                          &lt;RowDefinition Height="Auto"/&gt;
                                          &lt;RowDefinition Height="*"/&gt;
                                      &lt;/Grid.RowDefinitions&gt;
                                      &lt;TextBlock Grid.Column="0"
                                     Grid.ColumnSpan="2"
                                     Grid.Row="0"
                                     HorizontalAlignment="Center"
                                     VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
                                      &lt;ItemsControl Grid.Column="0"
                                                    Grid.Row="1"
                                                    HorizontalAlignment="Left"
                                                    ItemsSource="{Binding Path=.}"&gt;
                                          &lt;ItemsControl.ItemTemplate&gt;
                                              &lt;DataTemplate&gt;
                                                  &lt;TextBlock Style="{StaticResource LabelRowTextBlockStyle}"/&gt;
                                              &lt;/DataTemplate&gt;
                                          &lt;/ItemsControl.ItemTemplate&gt;
  
                                      &lt;/ItemsControl&gt;
                                  &lt;/Grid&gt;
                              &lt;/Border&gt;
                          &lt;/Grid&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>The TextBlock-Style:</p>
  
  <pre class="lang-wpf prettyprint-override"><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
      &lt;Style x:Key="LabelRowTextBlockStyle"
             TargetType="TextBlock"&gt;
          &lt;Setter Property="Margin"
                  Value="0,5"/&gt;
          &lt;Setter Property="Height"
                  Value="20"/&gt;
          &lt;Setter Property="Width"
                  Value="200"/&gt;
          &lt;Setter Property="Text"
                  Value="{Binding Content}"/&gt;
          &lt;Setter Property="Visibility"
                  Value="{Binding Visibility}"/&gt;
      &lt;/Style&gt;    
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>The property to which the ItemsControl is bound:</p>
  
  <pre class="lang-cs prettyprint-override"><code>    public List&lt;AlternativeAdressLetterLabel&gt; AlternativeAdressLabelList
              {
                  get { return this._alternativeAdressLabelList; }
                  set { this.SetProperty( ref this._alternativeAdressLabelList, value); }
              }
  
  The list-class which fundamental inherits from List&lt;LabelRow&gt;
  
  &lt;!-- language: c# --&gt;
  
      public class AlternativeAdressLetterLabel : DbConnectedLabelRowList
      {
  
          #region fields
  
          private string _sNumber;
          private Dictionary&lt;int, string&gt; _acountingArea;
  
          #endregion
  
          #region properties
  
          public string SNumber
          {
              get { return this._sNumber; }
              set
              {
                  this._sNumber = value;
                  this.OnPropertyChanged();
              }
          }
  
          public Dictionary&lt;int, string&gt; AcountingArea
          {
              get { return this._acountingArea; }
              set
              {
                  this._acountingArea = value;
                  this.OnPropertyChanged();
              }
          }
  
          #endregion
  </code></pre>
  
  <p>and finally the properties of the class which is hold by <code>AlternativeAdressLetterLabel</code></p>
  
  <pre class="lang-cs prettyprint-override"><code>    public string Content
      {
          get { return this._content; }
          set { SetProperty(ref this._content, value); }
      }
  
      public string Visibility
      {
          get { return this._visibility; }
          set { SetProperty(ref this._visibility, value); }
      }
  </code></pre>
  
  <p>Thanks in advance :)</p>