xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.91k stars 879 forks source link

Enter after changing DateTimePicker in a DataGrid... #884

Open xceedsoftware opened 7 years ago

xceedsoftware commented 7 years ago

geardoom3[CodePlex]
When I press ENTER after I'm finished editing a DateTimePicker which is in a DataGrid it doesn't trigger RowEditEnding. ltDataGridTemplateColumn ClipboardContentBinding=quot{x:Null}quot Header=quotCreated Datequotgt ltDataGridTemplateColumn.CellTemplategt ltDataTemplategt ltxctk:DateTimePicker AutoCloseCalendar=quotTruequot Value=quot{Binding CreatedDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}quot/gt lt/DataTemplategt lt/DataGridTemplateColumn.CellTemplategt lt/DataGridTemplateColumngt

xceedsoftware commented 7 years ago

BoucherS[CodePlex]
Hi,

If you use the Xceed DataGrid, it will work when subscribing to specific row.EditEnding event : xcdg:DataGridControl x:Name=grid xcdg:DataGridControl.Columns xcdg:Column FieldName=ID/ xcdg:Column FieldName=Name / xcdg:Column FieldName=Birthday/ /xcdg:DataGridControl.Columns /xcdg:DataGridControl

private void MainWindow_Loaded( object sender, RoutedEventArgs e ) { foreach( object item in grid.Items ) { var row = grid.GetContainerFromItem( item ) as DataRow; row.EditEnding += row_EditEnding; } }

private void row_EditEnding( object sender, Xceed.Wpf.Toolkit.Core.CancelRoutedEventArgs e ) { } If you use the Microsoft DataGrid, you need to put the DatePicker in a DataGridTemplateColumn.CellEditingTemplate tag, not a DataGridTemplateColumn.CellTemplate tag : DataGrid x:Name=grid AutoGenerateColumns=False DataGrid.Columns DataGridTextColumn Header=ID Binding={Binding ID} / DataGridTemplateColumn ClipboardContentBinding={x:Null} Header=Created Date DataGridTemplateColumn.CellTemplate DataTemplate TextBlock Text={Binding Birthday} / /DataTemplate /DataGridTemplateColumn.CellTemplate DataGridTemplateColumn.CellEditingTemplate DataTemplate xctk:DateTimePicker AutoCloseCalendar=True Value={Binding Birthday, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged} / /DataTemplate /DataGridTemplateColumn.CellEditingTemplate /DataGridTemplateColumn DataGridTextColumn Header=Name Binding={Binding Name} / /DataGrid.Columns /DataGrid

private void MainWindow_Loaded( object sender, RoutedEventArgs e ) { grid.RowEditEnding += grid_RowEditEnding; }

private void grid_RowEditEnding( object sender, DataGridRowEditEndingEventArgs e ) { }