Frage

<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

War es hilfreich?

Lösung

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>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top