void pivotGridControl1_OnCellEdit(DependencyObject sender, PivotCellEditEventArgs args) { PivotGridControl pivotGrid = (PivotGridControl)sender; PivotGridField fieldExtendedPrice = pivotGrid.Fields["ExtendedPrice"]; PivotDrillDownDataSource ds = args.CreateDrillDownDataSource(); decimal difference = args.NewValue - args.OldValue; decimal factor = (difference == args.NewValue) ? (difference / ds.RowCount) : (difference / args.OldValue); for (int i = 0; i < ds.RowCount; i++) { decimal value = Convert.ToDecimal(ds[i][fieldExtendedPrice]); decimal newValue = (value == 0m) ? factor : value * (1m + factor); ds.SetValue(i, fieldExtendedPrice, newValue); } }
static void OnEditValue(object sender) { PivotGridControl pivotGrid = sender == null ? null : FindParentPivotGrid((DependencyObject)sender); if (pivotGrid != null) { if (GetEditedCell(pivotGrid) == null) { return; } SetEditedCell(pivotGrid, null); } TextEdit edit = sender as TextEdit; if (edit == null || edit.DataContext as CellsAreaItem == null) { return; } CellsAreaItem item = edit.DataContext as CellsAreaItem; decimal newValue; decimal oldValue; if (edit.EditValue != null && decimal.TryParse(edit.EditValue.ToString(), out newValue)) { if (item.Value == null || !decimal.TryParse(item.Value.ToString(), out oldValue)) { edit.EditValue = null; return; } if (pivotGrid == null) { return; } RoutedEventArgs args = new PivotCellEditEventArgs(OnCellEditEvent, item, pivotGrid, newValue, oldValue); pivotGrid.RaiseEvent(args); pivotGrid.RefreshData(); } else { } }