views:

66

answers:

1

In a standanlone WPF app I got a DataGrid to enter some values. For text values this works nicely just like this:

<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding MyCollection}">
  <DataGrid.Columns>
    <DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
    <DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
  </DataGrid.Columns>
</DataGrid>

But now I'd like to enter some dates using a DatePicker instead of a text entry, but there is no or something similar.

So how do I get a DatePicker (or anything else) as entry field in the DataGrid?

+1  A: 

Use the DataGridTemplateColumn. There in you can specify the templates for edit and normal state. Look at the example in the article. It will show you how to use.

HCL