Posted 6 May 2018, 9:15 pm EST
Dear C1 Support Team
Because my requirements I need dynamic generate column in code behind, and moreover It has Binding Converter, ConverterParameter. So I do it as below but it NO call to Converter when generate column. I spent much time to debug and found solution but I can’t . Could you to see and Show me any wrong. I am so appreciate !
private static void ColumnsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
C1FlexGrid grid = d as C1FlexGrid;
if (grid == null || e.NewValue == null) return;
IEnumerable<IHeaderCell> cols = e.NewValue as IEnumerable<IHeaderCell>; if (cols == null) return; int num = 0; foreach (IHeaderCell col in cols) { Column gridViewColumn = new Column(); if (!string.IsNullOrEmpty(col.CellConverterKey) && grid.Resources.Contains(col.CellConverterKey)) { var binding = new Binding(); binding.Converter = grid.Resources[col.CellConverterKey] as IValueConverter; binding.ConverterParameter = col; gridViewColumn.Binding = binding; } if (col.CellTemplateKeySelector != null) { string cellTemplateResourceKey = col.CellTemplateKeySelector(null); if (grid.Resources.Contains(cellTemplateResourceKey)) { gridViewColumn.CellTemplate = grid.Resources[cellTemplateResourceKey] as DataTemplate; } } grid.Columns.Add(gridViewColumn); ++num; } }