Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Binding SL 2.0 DataGrid Cell by Cell Instead of Itemsource
1 replies. Latest Post by yifung on March 25, 2008.
(0)
deepty.3...
Member
78 points
91 Posts
03-25-2008 8:21 AM |
Hi,
Can I know how to bind the SL 2.0 DataGrid Cell by Cell for each row instead of assigning a collection to Itemsource?
Like for sample
DataGrid obj = new DataGrid();
obj.Columns[0][1] = "123";
obj.Columns[0][2] = "456";
obj.Columns[1][1] = "1234";
obj.Columns[1][2] = "4567";
and so on........................
Can you give me the sample code so that it will be clear?
Thanks,
T sudarshan Reddy.
yifung
Contributor
3315 points
541 Posts
03-25-2008 3:38 PM |
The DataGrid does not have an unbound mode so you cannot set content cell by cell. To get that same effect, you can create the columns you want with the proper binding and then set the ItemsSource. Something like this:
<d:DataGrid>
<d:DataGrid.Columns>
<d:DataGridTextBoxColumn DisplayMemberBinding="{Binding FirstName}" />
<d:DataGridTextBoxColumn DisplayMemberBinding="{Binding LastName}" />
</d:DataGrid.Columns>
<d:DataGrid.ItemsSource>
<local:CustomerList />
</d:DataGrid.ItemsSource>
</d:DataGrid>
Yifung