/// <summary> /// Clears the contents of our columns and resets our state. /// </summary> public void Clear() { foreach (ColumnManager manager in this.columns) { manager.StackPanel.Children.Clear(); } this.rows = new Collection <DataBoundRow>(); this.hashGroupings.Clear(); this.groupingTitles.Clear(); this.lastRow = null; this.firstVisibleItemIndex = 0; this.lastVisibleItemIndex = -1; SummaryManager summaryMgr = this.columns[0].SummaryManager; if (summaryMgr != null && summaryMgr.MainPanel != null) { summaryMgr.MainPanel.Visibility = Visibility.Collapsed; } }
/// <summary> /// Updates the summary for Look ahead/behind columns. /// </summary> /// <param name="dataContext">The data context for summary.</param> /// <param name="rowIndex">Row index for the current binding.</param> /// <param name="behindSummary">Specifies if the summary is for look behind or not.</param> internal void UpdateSummary(object dataContext, int rowIndex, bool behindSummary) { if (this.columns.Count > 0 && this.columns[0].SummaryManager != null) { SummaryManager summaryManager = this.columns[0].SummaryManager; Panel dataTemplate; if (summaryManager.MainPanel.Children.Count == 0) { object templateObject = DataTemplateHelper.LoadContent(summaryManager.CellTemplate); dataTemplate = templateObject as Panel; dataTemplate.DataContext = dataContext; summaryManager.MainPanel.Children.Insert(0, dataTemplate); } else { dataTemplate = summaryManager.MainPanel.Children[0] as Panel; dataTemplate.DataContext = dataContext; } dataTemplate.Tag = String.Format(System.Globalization.CultureInfo.CurrentCulture, WrapDataGridResources.SummaryCellTemplateTagFormat, rowIndex + (behindSummary ? -1 : 1)); } }
/// <summary> /// Creates Look behind column. /// </summary> private void CreateLookBehindColumns() { if (this.lookBehindCellTemplate == null) { throw new ArgumentNullException("Look behind cell template must be defined", (Exception)null); } if (this.lookBehindSummaryCellTemplate == null) { throw new ArgumentNullException("Look behind summary cell template must be defined", (Exception)null); } this.lookBehindView = new LookBehindView(); this.lookBehindColumn = new ColumnManager(); Grid lookBehindLayout = DataTemplateHelper.LoadContent((this.layoutRoot.Resources["LookBehindCellTemplateGridLayout"] as DataTemplate)) as Grid; lookBehindLayout.SetValue(Grid.ColumnSpanProperty, this.WrapDataGridColumns.Count + 1); DataTemplate cellTemplate = this.layoutRoot.Resources["LookBehindCellTemplate"] as DataTemplate; StackPanel summaryPanel = new StackPanel(); summaryPanel.SetValue(Grid.RowProperty, 0); summaryPanel.SetValue(Grid.ColumnProperty, 0); StackPanel columnPanel = new StackPanel(); columnPanel.HorizontalAlignment = HorizontalAlignment.Right; columnPanel.Orientation = Orientation.Horizontal; columnPanel.SetValue(Grid.RowProperty, 0); columnPanel.SetValue(Grid.ColumnProperty, 1); SummaryManager summary = new SummaryManager(); summary.CellTemplate = this.lookBehindSummaryCellTemplate; summary.MainPanel = summaryPanel; this.lookBehindColumn.SetValue(Grid.ColumnSpanProperty, 5); this.lookBehindColumn.MasterCellTemplate = cellTemplate; this.lookBehindColumn.CellTemplate = this.lookBehindCellTemplate; this.lookBehindColumn.StackPanel = columnPanel; this.lookBehindColumn.SummaryManager = summary; this.lookBehindColumn.GridLayout = lookBehindLayout; }