title: C# data binding nested ItemsControl wpf
body: <p>I want to build a UserInterface like this (a timeline for a video editor)
  <a href="https://i.stack.imgur.com/fkD6l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fkD6l.png" alt="enter image description here"></a></p>
  
  <p>and I have all classes:</p>
  
  <pre><code>public class Timeline
      {
          public Timeline()
          {
              groups = new ObservableCollection&lt;Group&gt;();
          }
          public ObservableCollection&lt;Group&gt; groups { get; set; }
  
      }
  
  public class Group
  {
      public string Name { get; set; }
  
      public TrackGroup()
      {
          tracks = new List&lt;Track&gt;();
      }
  
      public List&lt;Track&gt; tracks { get; set; }
  }
  
  public class Track
  {
      public Track()
      {
          units= new ObservableCollection&lt;Unit&gt;();
      }
      public ObservableCollection&lt;Unit&gt; units { get; set; }
  }
  
  public class Unit
  {
      public string unitName { get; set; }
  }
  </code></pre>
  
  <p>And in Main I have this:</p>
  
  <pre><code>public Timeline timeline = new Timeline();
  public Unit unit = new Unit();
  public Track track = new Track();
  public Group group = new Group();
  track.units.Add(unit);
  group.tracks.Add(track);
  timeline.groups.Add(group);
  </code></pre>
  
  <p>And in Main.xaml(not complete because it doesn't work)</p>
  
  <pre><code>&lt;ListBox
          HorizontalContentAlignment="Stretch"
          ItemsSource="{Binding timeline.groups}"&gt;
                  &lt;ListBox.ItemTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;DockPanel LastChildFill="True"&gt;
                              &lt;ItemsControl ItemsSource="{Binding timeline.groups.tracks}"&gt;
                                  &lt;ItemsControl.ItemTemplate &gt;
                                      &lt;ItemsControl ItemsSource="{Binding timeline.groups.tracks.units}"&gt;
                                          &lt;ItemsControl.ItemTemplate &gt;
                                          &lt;/ItemsControl.ItemTemplate &gt;
                                      &lt;/ItemsControl&gt;
                                  &lt;/ItemsControl.ItemTemplate&gt;
                              &lt;/ItemsControl&gt;
                          &lt;/DockPanel&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/ListBox.ItemTemplate&gt;
              &lt;/ListBox&gt;
  </code></pre>
  
  <p>How can I binding each itemssource? because <strong>timeline</strong>, <strong>group</strong>, <strong>track</strong> all are list, so I need to show them in ItemsControl. I was very confused</p>