Esempio n. 1
0
        internal bool RaiseCurrentCellValidatingEvent(object oldValue, object newValue, GridColumn column, out object changedNewValue, RowColumnIndex currentCellIndex, FrameworkElement currentCell, out string errorMessage, object rowData)
        {
            if (this.dataGrid.CanQueryCoveredRange() && !this.dataGrid.MergedCellManager.CanRasieEvent)
            {
                changedNewValue = newValue;
                errorMessage    = string.Empty;
                return(true);
            }

            var e = new CurrentCellValidatingEventArgs(dataGrid)
            {
                OldValue = oldValue,
                NewValue = newValue,
                Column   = column,
                IsValid  = true,
                RowData  = rowData
            };
            var isValid = dataGrid.RaiseCurrentCellValidatingEvent(e);

            changedNewValue = e.NewValue;

            var cell = currentCell as GridCell;

            if (!isValid)
            {
                cell.SetCellValidationError(e.ErrorMessage, false);
            }
            else if (errorMessages == null || !(errorMessages.Keys.Any(x => x == column.MappingName)))
            {
                cell.RemoveCellValidationError(false);
            }


            errorMessage = e.ErrorMessage;
            return(isValid);
        }