edit Datetimepicker in datagrid.

Aug 12, 2011 at 2:37 PM

Hello,

I got a problem when editing the datetime value in the datagrid cell.

for example, if I edit the "name" column, and messagebox.show(datagrid1.item(0).name) would show different value.

however, when I edit the log_time column, messagebox.show(datagrid1.item(0).log_time) always show the original loaded value.

anyway to set the item value change by editing the datatimepicker directly in the datagrid cell?

thanks!!

 

<DataGrid.Columns>
            <DataGridTextColumn IsReadOnly="False"   Header="name"     Binding="{Binding name}" />
                 <DataGridTemplateColumn IsReadOnly="False"  Header="log_time"
     Width="105" CanUserSort="True">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <extToolkit:DateTimePicker    Value="{Binding log_time,Mode=TwoWay}"  Format="Custom" FormatString="hh:mm:ss"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                   
                </DataGridTemplateColumn>

            </DataGrid.Columns>
        </DataGrid>

Aug 12, 2011 at 4:20 PM

Try using it as the cell editing template.  When it is used as the CellTemplate, the DatGrid is not in edit mode.  The DataGrid will go into edit mode when the cell editing template becomes available.

Aug 12, 2011 at 4:27 PM

Or you can simply use the UpdateSourceTrigger as follows:

                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <extToolkit:DateTimePicker Value="{Binding Date, UpdateSourceTrigger=PropertyChanged}"  Format="Custom" FormatString="hh:mm:ss"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>