title: In the built-in WPF DataGrid, can I set the datasource for a DataGridTemplateColumn?
body: <p>In this hypothetical example, imagine I have an object FooSet that has five properties Foo1, Foo2, Foo3 Foo4 and Foo5 all of which are type Foo which itself has several properties.  Finally, I have a DataTemplate called FooTemplate that knows how to display objects of type Foo in a graphical way.</p>
  
  <p>Now when using the built-in DataGrid, ItemsSource is a collection of FooSet objects.  What I want to do is set up five templated columns that all use the FooTemplate data template.  However, the DataGrid's template column type doesn't let me set the data source for that column (e.g. Foo1, Foo2, etc.) so I end up duplicating the template, once for each column, just changing Foo1.SomeProp to Foo2.SomeProp in the template's bindings, which is ridiculous of course.  But I for the life of me can't find how to say 'Column B uses Foo2 as it's data source.'</p>
  
  <p>Here's some Pseudo-XAML to show what I want...</p>
  
  <pre><code>&lt;Resources&gt;
      &lt;DataTemplate TargetType="Foo"&gt;
          &lt;StackPanel&gt;
              &lt;local:FooPropAControl Value="{Binding FooPropA}" /&gt;
              &lt;local:FooPropBControl Value="{Binding FooPropB}" /&gt;
              &lt;local:FooPropCControl Value="{Binding FooPropC}" /&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
  &lt;/Resources&gt;
  
  &lt;DataGrid ItemsSource="{Binding MyItems}" AutoGenerateColumns="false"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTemplateColumn DataSource="{Binding Foo1}" /&gt;
          &lt;DataGridTemplateColumn DataSource="{Binding Foo2}" /&gt;
          &lt;DataGridTemplateColumn DataSource="{Binding Foo3}" /&gt;
          &lt;DataGridTemplateColumn DataSource="{Binding Foo4}" /&gt;
          &lt;DataGridTemplateColumn DataSource="{Binding Foo5}" /&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Even if I have to explicitly specify the template in the column, that's still fine.  It's setting the data source for that column to a property of FooSet so I can just use one DataTemplate.  All the other columns let you set some binding that does that.  I even tried subclassing DataGridTemplateColumn to add DataSource but didn't get too far (my guess is because there isn't a column per se but rather that dictates how cells in rows are generated, but that's just a guess.)</p>
  
  <p>Now I know the 3rd-party Xceed grid lets you specify exactly that but I'm hoping for a native solution.</p>
  
  <p>So, howzyadoodat?  Or can you?</p>
  
  <p>M</p>