I need to add columns to silverlight columns at runtime and also perform the bindings for the columns.
This is how i do it statically in xaml
<sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="CriteriaName" Width="2*" Binding="{Binding Path=[CriteriaName]}" IsReadOnly="True" />
Now i want do the same in code behind,
here is what i have done
foreach(string Col in lColumnNames)
{
DataGridTextColumn DGCol=new DataGridTextColumn();
DGCol.Header= Col;
Binding lObjBinding = new Binding(Col);
lObjBinding.Mode = BindingMode.OneWay;
DGCol.Binding = lObjBinding;
GrdQuickFindResult.Columns.Add(DGCol);
}
This is not working.All i can see are blank rows in the DataGrid,as if the binding hasn't happened. Pls check and tell me if all the things that i have done using xaml is done using C# as well or is there some property that is left to be set in the Binding Object that i have created.
Thanx