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.
Hello Stefan,
thank you for your example and fast response! The XAML looks similar to mine. Your example runs and runs, but my solution throws a runtime exception "Infragistics.Controls.Grids.InvalidColumnKeyException" there must be something wrong with my ItemSource. Funny, the regular <DataGrid> works fine with the same source.. aahhh ohh.. my ItemSource was a DataTable.. now i'm using a DataView and everything is fine. Thanks!
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.