title: How to assign ItemsSource property
body: <p>Okay, sorry for my previous mess.</p>
  
  <p>The situation is this:
  I have two custom objects defined as follows:
  MainObject:</p>
  
  <pre><code>public class MainObject
  {
      private string mainObjectName;
      public string MainObjectName { get { return mainObjectName; } }
  
      private List&lt;SubObject&gt; subObjectData;
      public List&lt;SubObject&gt; SubObjectData { get { return subObjectData; } }
  
      public MainObject(string name, List&lt;SubObject&gt; objectData)
      {
          mainObjectName = name;
          subObjectData = objectData;
      }
  }
  </code></pre>
  
  <p>SubObject:</p>
  
  <pre><code>public class SubObject
  {
      private string subObjectName;
      public string SubObjectName { get { return subObjectName; } }
  
      private List&lt;int&gt; integerData;
      public List&lt;int&gt; IntegerData { get { return integerData; } }
  
      public SubObject(string name, List&lt;int&gt; data)
      {
          subObjectName = name;
          integerData = data;
      }
  }
  </code></pre>
  
  <p>I also have a viewmodel which for simplicity defines some data using those two objects as follows:VM</p>
  
  <pre><code>public List&lt;Model.MainObject&gt; VMList = new List&lt;Model.MainObject&gt;()
      {
          new Model.MainObject("MainItem1", new List&lt;Model.SubObject&gt;()
          {
              new Model.SubObject("SubItem1", new List&lt;int&gt;() { 1,6,3}),
              new Model.SubObject("SubItem2", new List&lt;int&gt;() { 5,2,9})
          }),
          new Model.MainObject("MainItem2", new List&lt;Model.SubObject&gt;()
          {
              new Model.SubObject("SubItem1", new List&lt;int&gt;() { 0,3,1}),
              new Model.SubObject("SubItem2", new List&lt;int&gt;() { 7,5,2})
          })
      };
  </code></pre>
  
  <p>now I have the following UI</p>
  
  <pre><code>&lt;Grid&gt;
      &lt;ItemsControl Name="MainObjectIC"&gt;
          &lt;ItemsControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;Grid&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition/&gt;
                          &lt;ColumnDefinition/&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;TextBlock Text="{Binding MainObjectName}"/&gt;
                      &lt;ItemsControl Name="SubObjectIC"&gt;
                          &lt;ItemsControl.ItemTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;TextBlock Text="{Binding SubObjectName}"/&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/ItemsControl.ItemTemplate&gt;
                      &lt;/ItemsControl&gt;
                  &lt;/Grid&gt;
              &lt;/DataTemplate&gt;
          &lt;/ItemsControl.ItemTemplate&gt;
      &lt;/ItemsControl&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>I assign the ItemsSource of the MainObjectIC in the code behind like so:</p>
  
  <pre><code>ViewModel.VM dc = new ViewModel.VM();
  
      public MainWindow()
      {
          InitializeComponent();
          DataContext = dc;
          MainObjectIC.ItemsSource = dc.VMList;
      }
  </code></pre>
  
  <p>I also want to assign the ItemsSource to the SubObjectIC but to do that I have to get that ItemsControl object. And this is what I am trying to achieve.</p>
  
  <p>From what I understood it may be a very very bad and useless to assign the ItemsSource property from the code behind.</p>