Reputation: 717
I was having the delayed-binding problem mentioned here:
WPF DataGrid source updating on cell changed
My source properties were being updated when the user pressed Enter but not when s/he pressed Tab.
I found an excellent advice in the post above: UpdateSourceTrigger=LostFocus
(that is the answer with most upclicks, BTW) and now the updates are done as desired, when the user leaves the cell horizontally or vertically. One problem remains, however: pressing Enter while in the bottom row.
The relevant columns are defined as follows:
<DataGridTextColumn Header="Quantity"
Width="Auto"
Binding="{Binding Path=Quantity,
UpdateSourceTrigger=LostFocus}">
</DataGridTextColumn>
Isn't there something like: UpdateSourceTrigger=EditEnded
??
Posterior addition:
The Explicit
option seems quite promising:
My event handler would only care about events triggered by the last row and call the UpdateSource
method. If that is the solution, I only need to know what to place to the left of .UpdateSource()
.??
Upvotes: 0
Views: 169
Reputation: 44038
Just tried this:
<DataGridTextColumn Header="Quantity"
Width="Auto"
Binding="{Binding Path=Quantity, UpdateSourceTrigger=PropertyChanged}">
</DataGridTextColumn>
And it works fine. The binding is updated on every key press, rather than when changing the row or else.
Upvotes: 1