I have question how i can bind datagrid column to collection?
dataGrid1.Columns.Add(new DataGridTemplateColumn { Header="d", Binding = "RoomNumber"});
binding does not exsists what can i use to bind?
it work perfectly but i need to bind it with code behind
<DataGridTextColumn Header="Room Number" Binding="{Binding RoomNumber}"/>
As far as i understand you want to add data grid column from code behind and that column should work with binding..?
here is sample snippet to add datagrid column from code behind
With this approach you can add as many columns as you want and you can give data binding at run time for each column and you can specify itemssource at once….
make sure to mark AutoGenerateColumns=”False” in your data grid so that you can avoid unwanted columns get added from itemssource..