所以这是我的datagrid:
<DataGrid ItemsSource="{Binding Path=Attributes}" AutoGenerateColumns="True" Height="95" HorizontalAlignment="Left" Margin="69,99,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="364" Grid.Column="1" />
并且对我的viewmodel的绑定很好。
itemssource属性是IEnumerable<KeyValuePair<QuestionAttributeDefinition, string>>
类QuestionAttributeDefinition有一个属性Name。现在我想在我的网格中显示:
QuestionAttributeDefinition.Name和keyvaluepair的字符串。但是,当我想显示这个数据网格时,现在实现它显示:
Domain.Questions.QuestionAttributeDefinition和字符串(字符串正常)
如何显示QuestionAttributeDefinition的属性'Name'?
答案 0 :(得分:0)
尝试自己定义列:
<DataGrid ItemsSource="{Binding Path=Attributes}" AutoGenerateColumns="False" Height="95" HorizontalAlignment="Left" Margin="69,99,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="364" Grid.Column="1">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Key.Name}">
<DataGridTextColumn Header="Value" Binding="{Binding Value}">
<DataGrid.Columns>
</DataGrid>