Skip to main content

Microsoft Silverlight

Answered Question Binding SL 2.0 DataGrid Cell by Cell Instead of Itemsource RSS Feed

(0)

deepty.302472
deepty.3...

Member

Member

78 points

91 Posts

Binding SL 2.0 DataGrid Cell by Cell Instead of Itemsource

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
yifung

Contributor

Contributor

3315 points

541 Posts

Microsoft
Answered Question

Re: Binding SL 2.0 DataGrid Cell by Cell Instead of Itemsource

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>

Thanks,

Yifung

Yifung Lin [MSFT]
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities