Hi,
I've got a xamdatagrid and am making use of the new IDataErrorInfo stuff for cell validation. The problem scenario I have is that the grid is editable. I want to bind a 'Save' button so that it will be enabled when:
1. The user has changed something.
2. The data in the grid is valid (according to the IDataErrorInfo implementation).
I've done the IDataErrorInfo part and it's working nicely.
I was going to have a 'CanSave' dependency property, with its value based on an 'IsDirty' flag (set in the CellChanged event handler for the grid), combined with the valid state of the grid.
The problem is that when I examine the e.Cell.DataError as below:
private void dgConfig_CellChanged(object sender, Infragistics.Windows.DataPresenter.Events.CellChangedEventArgs e) { IsDirty = true;
if (!string.IsNullOrEmpty((string)e.Cell.DataError))
........
I find that it isn't yet set. Any clues? Am I going about this the wrong way? Can I force the validation? Is there an 'IsValid' property for the xamDataGrid (I couldn't find one).
Any help would be greatly appreciated.
Thanks,
John
PS The validation seems to be called *several* times for the cell.
Hello John,
The xamDataGrid validation happens only when you try to exit the editor’s EditMode (when pressing enter, tab selecting a different element etc.) as shown in the online documentation: http://help.infragistics.com/Help/NetAdvantage/WPF/2009.2/CLR3.5/html/xamDataGrid_Validating_Edited_Cell_Data_in_xamDataGrid.html
Since CellChanged fires on any user input therefore is before the EditModeEnding event, there is no DataError.
You can perform the same actions and set the same data field from a different event. E.g one that is fired on or after the validation (EditModeEnding/Enede, RecordUpdating/Updated). Hope this helps.
Sincerely,
Petar Monov,
DS Engineer,
Infragistics Bulgaria