You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The in WPF general default behavior for an editable control that supports text input is to push binding update to source when the control loses focus.
When the user closes the active window and focused elements automatically loose focus and this causes any edits on the focused control to be pushed before the window closes.
However with the DataGrid control, if the window is closed and there is a text cell in edit mode it doesn't cause the binding to push the cell contents.
This issue seems to be due to the cell control retaining keyboard focus after it has lost logical focus. Which would make since if the cell was composed of multiple separate controls which could lose and gain focus while the cell was still being edited.
See DataGridCell.OnAnyLostFocus
However when logical focus leaves the visual hierarchy of the current cell, then the current cell selection should be cleared.
Set Binding.UpdateSourceTrigger to UpdateSourceTrigger.LostFocus for each editable data grid column.
This workaround method does have some side effects: that I'm aware of, cells always push binding when cell lose focus rather than when row exited.
Impact
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered:
BenCamps
changed the title
When DataGrid cell is in edit mode when window closed, edits are not commted
When window closed with DataGrid cell is in edit mode, active edits are not committed
Oct 4, 2024
Description
The in WPF general default behavior for an editable control that supports text input is to push binding update to source when the control loses focus.
When the user closes the active window and focused elements automatically loose focus and this causes any edits on the focused control to be pushed before the window closes.
However with the DataGrid control, if the window is closed and there is a text cell in edit mode it doesn't cause the binding to push the cell contents.
This issue seems to be due to the cell control retaining keyboard focus after it has lost logical focus. Which would make since if the cell was composed of multiple separate controls which could lose and gain focus while the cell was still being edited.
See DataGridCell.OnAnyLostFocus
However when logical focus leaves the visual hierarchy of the current cell, then the current cell selection should be cleared.
Reproduction Steps
While running program
Attached simple application for reproducing issue: WpfDataGridAppClosingIssue.zip
cell
Expected behavior
When app closes current edits are committed
Actual behavior
cell edits are not committed when window closes
Regression?
No response
Known Workarounds
Set Binding.UpdateSourceTrigger to UpdateSourceTrigger.LostFocus for each editable data grid column.
This workaround method does have some side effects: that I'm aware of, cells always push binding when cell lose focus rather than when row exited.
Impact
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: