Does the DataError property only support string type errors?
I'm trying to customise it to support different kinds of error levels and I need this DataError property to return an object instead of a string.
Hello Anthony,
CellValuePresenter DataError property returns the associated Field's DataError as an object. A DataError can provide error information regarding the individual fields of the data item by implementing IDataErrorInfo interface. If the data item associated with the data record implements IDataErrorInfo, this property returns the field error if any for this cell - the value returned by the IDataErrorInfo's Item[fieldName] indexer.
Based on the underlying data item’s IDataErrorInfo implementation, GetCellDataError(Field) method returns the DataError object of the specific field that was passed into it as input parameter.
Please let me know if you have any questions.
I decompiled and found this code
public object DataError { get { return this.GetValue(CellValuePresenter.DataErrorProperty); } } internal void UpdateDataError() { ValueEditor editor = this.Editor; Field field = this.Field; DataRecord record = this.Record; bool flag1 = false; object obj = (object) null; bool flag2 = false; if (field != null && field.SupportDataErrorInfoResolved && field.Index >= 0) { if (editor != null && (this._editorInvalidValueInfoOverride != null || !editor.IsValueValid && !editor.IsInEditMode)) { flag1 = true; ValidationErrorInfo validationErrorInfo = this._editorInvalidValueInfoOverride != null ? this._editorInvalidValueInfoOverride : editor.InvalidValueErrorInfo; if (validationErrorInfo != null) obj = (object) validationErrorInfo.ErrorMessage; } else if (record != null && field != null) { flag1 = record.GetCellHasDataError(field); if (flag1) obj = record.GetCellDataError(field); } DataPresenterBase dataPresenter = field.DataPresenter; flag2 = flag1 || editor != null && editor.IsInEditMode || dataPresenter != null && dataPresenter.EditHelper.IsEditCell(this); } this.SetValue(DataRecordPresenter.HasDataErrorPropertyKey, KnownBoxes.FromValue(flag1)); this.SetValue(DataRecordPresenter.DataErrorPropertyKey, obj); this._pendingIsDataErrorTemplateActive = flag2; if (this.IsMeasureValid) this.SyncPendingIsDataErrorTemplateActive(); RecordSelector.UpdateDataErrorDisplayModeProperties(record, (DependencyObject) this); }
Is this suggesting that if i the field is editable with an editor, it will just use ErrorMessage instead of the object returned by INotifyDataErrorInfo.GetErrors?