public override DataTemplate SelectTemplate(object item, DependencyObject container) { Window mainWindow = Application.Current.MainWindow; CellsAreaItem cell = (CellsAreaItem)item; // Calculates the share of a cell value in the Row Grand Total value. double share = Convert.ToDouble(cell.Value) / Convert.ToDouble(cell.RowTotalValue); // Applies the Default template to the Row Grand Total cells. if (cell.RowValue == null) { return(mainWindow.FindResource("DefaultCellTemplate") as DataTemplate); } // If the share is too far from 50%, the Highlighted template is selected. // Otherwise, the Normal template is applied to the cell. if (share > 0.7 || share < 0.3) { return(mainWindow.FindResource("HighlightedCellTemplate") as DataTemplate); } else { return(mainWindow.FindResource("NormalCellTemplate") as DataTemplate); } }
internal PivotCellEditEventArgs(RoutedEvent routedEvent, CellsAreaItem cellItem, PivotGridControl pivot, decimal newValue, decimal oldValue) : base(routedEvent) { this.cellItem = cellItem; this.pivotGrid = pivot; this.newValue = newValue; this.oldValue = oldValue; Source = pivotGrid; }
private void cellShare_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { ProgressBarEdit bar = ((ProgressBarEdit)sender); CellsAreaItem item = bar.DataContext as CellsAreaItem; if (item == null) { return; } bar.Maximum = Convert.ToDouble(item.RowTotalValue); bar.Value = Convert.ToDouble(item.Value); }
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 { } }
static void OnTextEditMouseDown(object sender) { TextEdit edit = sender as TextEdit; CellsAreaItem cell = edit.DataContext as CellsAreaItem; if (edit == null || cell == null || cell.PivotGrid == null) { return; } #region EditingOfLastLevelCell bool lastLevelCell = cell.Item.RowValueType == DevExpress.XtraPivotGrid.PivotGridValueType.Value && cell.Item.IsFieldValueExpanded(cell.Item.RowField) && cell.Item.ColumnValueType == DevExpress.XtraPivotGrid.PivotGridValueType.Value && cell.Item.IsFieldValueExpanded(cell.Item.ColumnField); if (!lastLevelCell) { return; } #endregion edit.EditMode = EditMode.InplaceActive; edit.Focus(); Keyboard.Focus(edit); SetEditedCell(cell.PivotGrid, edit); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { CellsAreaItem cell = (CellsAreaItem)item; // Calculates the share of a cell value in the Row Grand Total value. double share = Convert.ToDouble(cell.Value) / Convert.ToDouble(cell.ColumnTotalValue); // Applies the Default template to the Row Grand Total cells. if (cell.ColumnValue == null) { return(DefaultCellTemplate); } // If the share is too far from 50%, the Highlighted template is selected. // Otherwise, the Normal template is applied to the cell. if (share > 0.7 || share < 0.3) { return(HighlightedCellTemplate); } else { return(NormalCellTemplate); } }