KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My WPF application generates sets of data which may have a different number of columns each time. Included in the output is a description of each column that will be used to apply formatting. A simplified version of the output might be something like: class Data { IList<ColumnDescription> ColumnDescriptions { get; set; } string[][] Rows { get; set; } } This class is set as the DataContext on a WPF DataGrid but I actually create the columns programmatically: for (int i = 0; i < data.ColumnDescriptions.Count; i++) { dataGrid.Columns.Add(new DataGridTextColumn { Header = data.ColumnDescriptions[i].Name, Binding = new Binding(string.Format("[{0}]", i)) }); } Is there any way to replace this code with data bindings in the XAML file instead?
Tags (comma-separated)
Save Edits
Cancel