wpf datagrid template column containing multiple controls

Aug 13, 2009 at 11:32 AM

Hi,

 

Can a wpf datagrid template column contain multiple controls? Or just a single control? For example, a date picker, a text box, and a check box in a single templte column. If this is possible, can someone please point me to some documentation on it or post sample syntax?

 

thanks!

 

/Justin 

Coordinator
Aug 13, 2009 at 1:26 PM

DataGridTemplateColumn has a CellTemplate and CellEditingTemplate DependencyProperty where you specify a DataTemplate.  The DataTemplate can really be anything you want.  Here's an example with a DatePicker, TextBox, and CheckBox:

<DataGridTemplateColumn>
 <DataGridTemplateColumn.CellTemplate>
  <DataTemplate>
   <StackPanel>
    <DatePicker />
    <TextBox />
    <CheckBox /> 
   </StackPanel>
  </DataTemplate>
 </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>