Hi, i'm trying to do something like this with XamDataGrid (2 or more values in one Column)
<DataGrid ItemSource="{Binding MyValues}">
<DataGrid.Columns> <DataGridTemplateColumn Header="Value A and B"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding ValueA}" /> <TextBlock Text="{Binding ValueB}" /> </StackPanel> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn>
</DataGrid>
But i don't know how?! I experimented with the CellValuePresenterStyle, but nothing worked for me.
Has anyone an Idea?
I just tried to solve the problem with XamGrid:
<ig:XamGrid ItemsSource="{Binding MyValues}" AutoGenerateColumns="False"> <ig:XamGrid.Columns> <ig:TemplateColumn Key="ValueA" IsReadOnly="True" HeaderText="Value A and B"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding ValueA}" />
<TextBlock Text="{Binding ValueB}" />
...
If i run this, for a half second are the values visible and than: invalidColumnKeyException because of Key="ValueA".
Really frustrating!
Hello Joscha,
Thank you for your post. I have been looking into it and I created a sample project for you following your scenario and everything seems to work ok on my side. I can say that the Columns’ Keys should match the properties names from the ItemsSource. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.