<DataGrid Name="myfirstdg"
Grid.Row="2"
AutoGenerateColumns="False"
CanUserSortColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
SelectionUnit="Cell">
<DataGrid.Columns>
<DataGridTextColumn Header="Date"
Binding="{Binding Path=date}"
Width="SizeToCells"
IsReadOnly="True"
MinWidth="100"/>
</DataGrid.Columns>
</DataGrid>
I have a simple DataGrid
with a DataGridTextColumn
in it. How do I add a Datepicker
to my DataGridTextColumn
?
As Nitesh said, use DataGridTemplateColumn
<DataGridTemplateColumn Header="Pick a Date">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding myDate}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<DatePicker SelectedDate="{Binding myDate}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With