views:

56

answers:

1

Hey there,

I am working with the the WPF Toolkit DataGrid and currently have a problem with committing data back to the source.

My grid is bound to a CLR object list and I have a converter with both the convert and convert back methods implemented.

The two way binding works fine if the user hits Enter in the cells but if they deselect or tab out of the cells the data that was typed is lost.

I have put a break on the CellEditEnding event and both events for Tab and Enter seem identical, but when it gets to the ConvertBack method on my converter the value is empty.

Any help would be much appreciated.

PS: the clients are already using the system with this bug and they are becoming increasing frustrated.

+1  A: 

Try changing the UpdateSourceTrigger parameter of your control's Binding to PropertyChanged instead of the default LostFocus.

Eg

          <TextBox
            Width="75"
            VerticalAlignment="Top"
            Margin="10"
            Text="{Binding
            Source={StaticResource data},
            Path=Age,
            UpdateSourceTrigger=PropertyChanged,
            ValidatesOnDataErrors=True,
            ValidatesOnExceptions=True}"
            Style="{StaticResource textBoxInError}" />
amazedsaint
This worked fine... obviously now evens are changed at each keystroke which works fine for now.But this obviously doesn't allow something to be typed... and then Escaped to cancel (like the IEditableObject).
Oliver