Immediate Edit when Typing on a DataGrid cell that contains a DatePicker

Sep 15, 2009 at 9:25 AM

I have a WPF Toolkit DataGrid bound to a datasource that has a date column.  I have successfully incorporated a WPF Toolkit DatePicker into the grid.  However, I don't like the editing sematics. 

This is how it currently behaves:

1. If user selects a cell containing DatePicker, cell is selected.  Nothing else happens.

2. If the user then starts typing on the cell, nothing happens [unlike on a cell bound to a date but with no date picker, which would go immediately into edit mode].

3. If the user double-clicks on a cell the cell goes into edit mode, and a little calendar icon appears.

4. If the users clicks on the calendar icon, the actual DatePicker drops down.

This is how I would like it to behave:

1. If user selects cell containing date, cell is selected.  Nothing else happens.

2. If the user then starts typing on the cell, it should immediately go into "edit mode", and the DatePicker drops down.  No need for the intermediate "Calendar icon" step.

2. Equally, if the user double clicks on the cell, it should immediately go into "edit mode" and the DatePicker drops down. No need for the intermediate "Calendar icon" step.

 

Is there some way this can be acheived with the current DataGrid / DatePickers ?  Or would this require changes to the WPFToolkit source?

 

Cheers,

 

JG

 

 

 

 

 <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<dg:DataGrid ItemsSource="{Binding}" Name="dataGrid" AutoGenerateColumns="False" Height="Auto" SelectionChanged="dataGrid_SelectionChanged">

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<dg:DataGrid.Columns><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<dg:DataGridTextColumn Binding="{Binding Path=EventTypeID}" Header="EventTypeID"/><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<dg:DataGridTextColumn Binding="{Binding Path=Comment}" Header="Comment" /><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<dg:DataGridTextColumn Binding="{Binding Path=EventDate}" Header="Event Date 2" /><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<dg:DataGridTemplateColumn Header="Event Date" MinWidth="30"><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<dg:DataGridTemplateColumn.CellTemplate><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<DataTemplate><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<TextBlock Text="{Binding Path=EventDate, StringFormat=dd-MMM-yyyy}" Margin="4" HorizontalAlignment="Right"/><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</DataTemplate><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</dg:DataGridTemplateColumn.CellTemplate><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<dg:DataGridTemplateColumn.CellEditingTemplate><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<DataTemplate><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

<dg:DatePicker Focusable="False" SelectedDate="{Binding EventDate, Mode=TwoWay}" /><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</DataTemplate><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</dg:DataGridTemplateColumn.CellEditingTemplate><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</dg:DataGridTemplateColumn>

 

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</dg:DataGrid.Columns><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font>
<font size="2" color="#a31515">

 

</font>

 

</dg:DataGrid>