views:

674

answers:

1

I have seen many examples of creating a WPF Toolkit DataGrid in XAML and it is possible to write certain tags and there will be some columns, rows, etc depending on what you wrote.

Lets say I have an empty (it has no columns, no rows, nothing) WPF Toolkit DataGrid that has been created in XAML how do I add columns in C# programmatically (not in XAML)?

Thank you for any help!

+3  A: 

This should work for you.

MyDataGrid.Columns.Add(new DataGridTextColumn()
{
    Header="MyHeader", 
    Binding=new Binding("MyProperty")
});
Ian Oakes