문제

<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

도움이 되었습니까?

해결책

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top