title: WPF DataGrid ContentControll bindng
body: <p>I want to make DataGrid with a structure as in image below.
  <img src="https://i.stack.imgur.com/zh2N9.png" alt="enter image description here"></p>
  
  <p>To have two TextBoxes in each cell. </p>
  
  <p>Ive made Class</p>
  
  <pre><code>public class ComplexTable : ViewModelBase
      {
          public ComplexTable()
          {
              FirstProperty = new FirstClass();
              SecondProperty = new Second();    
          }
          public class FirstClass
          {
              public FirstClass()
              {
                  First = "FirstString";
                  Second = "SecondString";
              }
              public string First { get; set; }
              public string Second { get; set; }
          }
  
          public class Second
          {
              public Second()
              {
                  Third = "ThirdString";
                  Fourth = "FourthString";
              }
              public string Third { get; set; }
              public string Fourth { get; set; }
          }
  
          public FirstClass FirstProperty { get; set; }
          public Second SecondProperty { get; set; }
      }
  
      public ObservableCollection&lt;ComplexTable&gt; _testCollection = new ObservableCollection&lt;ComplexTable&gt;();
      private ObservableCollection&lt;ComplexTable&gt; TestCollection
      {
          get { return _testCollection; }
          set
          {
              _testCollection = value;
              RaisePropertyChanged("TestCollection");
          }
  
      }
  </code></pre>
  
  <p>And a TestCollection that should be a ItemsSource for DataGrid.</p>
  
  <p>My DataGrid</p>
  
  <pre><code>&lt;DataGrid  CanUserAddRows="True"
                         ItemsSource="{Binding TestCollection}"&gt;
                  &lt;DataGrid.Columns&gt;
                      &lt;DataGridTemplateColumn Header="First Column"&gt;
                          &lt;DataGridTemplateColumn.CellEditingTemplate &gt;
                              &lt;DataTemplate &gt;
                                  &lt;ContentControl&gt;
                                      &lt;StackPanel&gt;
                                          &lt;TextBox Text=" "/&gt;
                                          &lt;TextBox Text=" "/&gt;
                                      &lt;/StackPanel&gt;
                                  &lt;/ContentControl&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
                      &lt;/DataGridTemplateColumn&gt;
  
                      &lt;DataGridTemplateColumn Header="Second Column"&gt;
                          &lt;DataGridTemplateColumn.CellEditingTemplate &gt;
                              &lt;DataTemplate &gt;
                                  &lt;ContentControl&gt;
                                      &lt;StackPanel&gt;
                                          &lt;TextBox Text=" "/&gt;
                                          &lt;TextBox Text=" "/&gt;
                                      &lt;/StackPanel&gt;
                                  &lt;/ContentControl&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
                      &lt;/DataGridTemplateColumn&gt;
                  &lt;/DataGrid.Columns&gt;
              &lt;/DataGrid&gt;
  </code></pre>
  
  <p>I can't figure out how to bind those textboxes. Or i went in a wrong direction?</p>