The above works and data show up as expected: Apple red Bana" /> The above works and data show up as expected: Apple red Bana" /> The above works and data show up as expected: Apple red Bana"/>

DomainDataSource datagrid binding in Silverlight

67 Views Asked by At
<sdk:DataGrid x:Name="AccountsDG" ItemsSource="{Binding Data, ElementName=AccountsDDS}"/>

The above works and data show up as expected:

Apple red
Banana yellow

I don't want all the columns shown in the datagrid, so I tried this:

<sdk:DataGrid x:Name="AccountsDG" ItemsSource="{Binding Data.FruitName, ElementName=AccountsDDS}"/>

However, instead of getting:

Apple
Banana

I got:

Char

A
p
p
l
e

1

There are 1 best solutions below

0
Sajeetharan On BEST ANSWER

If you dont want the columns to be autogenerated, you should define like below,

   <sdk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Data.FruitName,        ElementName=AccountsDDS} Name="AccountsDG" >
    <data:DataGrid.Columns>
        <data:DataGridTextColumn Header="YourColumName1" Binding="{Binding ColumName1}" />
        <data:DataGridTextColumn Header="YourColumName2" Binding="{Binding ColumName2}" />
     </data:DataGrid.Columns>
    </sdk:DataGrid>