I have a DataGridTemplateColumn
. Inside its CellEditingTemplate
, I put a DatePicker
control. Now if I want to edit the date, I have to click three times to let DatePicker
begin editing. Can someone let me know how I can get DatePicker
into edit mode with only two clicks? Also, if DataGridTemplateColumn
get focused, keyboard typing doesn't put DatePicker
into edit mode as well. It would be nice if it can be fixed as well.
DataGridTemplateColumn with DatePicker requires three clicks to edit the date
5.6k views Asked by Jing At
2
There are 2 answers
1
On
An easier solution would be to surround the datepicker with a grid and setting FocusManager on the DatePicker….
DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<Grid FocusManager.FocusedElement="{Binding ElementName=dPicker}">
<DatePicker x:Name="dPicker"
SelectedDate="{Binding HistoryDate, Mode=TwoWay}"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
You have to override the
PrepareCellForEdit
inDataGridTemplateColumn
as follows:XAML