public void Update() { double totalWidth = 0; int maxNestedLevels = 0; // initialize grid var panel = new Grid(); panel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(DataGridValueLablesCol.LevelHeaderHeight) }); panel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(DataGridValueLablesCol.LevelHeaderHeight) }); foreach (var col in InnerColumns) { // support nested scenarios var cc = col as DataGridValueLablesCol; if (cc != null) { cc.Update(); maxNestedLevels = Math.Max(cc.NestedLevels, maxNestedLevels); } panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(col.Width.Value) }); totalWidth += col.Width.Value; } // add global header var globalHeader = new ContentControl() { Content = CompositeHeader }; Grid.SetColumnSpan(globalHeader, InnerColumns.Count); panel.Children.Add(globalHeader); // add individual headers for (int i = 0; i < InnerColumns.Count; i++) { var col = InnerColumns[i]; // add nested headers var content = new DataGridColumnHeaderPresenter() { Content = col.Header, Background = new SolidColorBrush(Colors.Transparent) }; Grid.SetColumn(content, i); Grid.SetRow(content, 1); panel.Children.Add(content); } // update header & global width Header = panel; Width = new C1.WPF.DataGrid.DataGridLength(totalWidth); NestedLevels = 1 + maxNestedLevels; }
public void Update() { double totalWidth = 0; int maxNestedLevels = 0; // initialize grid var panel = new Grid(); panel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(CompositeColumn.LevelHeaderHeight) }); panel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(CompositeColumn.LevelHeaderHeight) }); foreach (var col in InnerColumns) { // support nested scenarios var cc = col as CompositeColumn; if (cc != null) { cc.Update(); maxNestedLevels = Math.Max(cc.NestedLevels, maxNestedLevels); } panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(col.Width.Value) }); totalWidth += col.Width.Value; } // add global header var globalHeader = new ContentControl() { Content = CompositeHeader }; Grid.SetColumnSpan(globalHeader, InnerColumns.Count); panel.Children.Add(globalHeader); // add individual headers for (int i = 0; i < InnerColumns.Count; i++) { var col = InnerColumns[i]; // add nested headers var content = new DataGridColumnHeaderPresenter() { Content = col.Header, Background = new SolidColorBrush(Colors.Transparent) }; Grid.SetColumn(content, i); Grid.SetRow(content, 1); panel.Children.Add(content); } // update header & global width Header = panel; Width = new C1.WPF.DataGrid.DataGridLength(totalWidth); NestedLevels = 1 + maxNestedLevels; }