Hello. Some of the rows in my XamDataGrid have child rows. I set the labels of the child rows' fields depending on the parent data records. Is there any way to set different field labels in every child row?
I have attached a screenshot, if it is unclear what i mean with "set different field labels in every child row".
Any help is appreciated.
That was exactly the solution I was looking for. Thank you, Rob.
Hi Freyth,
It seems that if I expand the parent records from the bottom up, this issue occurs. However, if I expand from the top down then it works as expected. It seems like there is a timing issue because when I stick a breakpoint in the template selector code it fires for every expanded child set but the parent is always the Seafood DataRecord. The grid probably updated the Content of the LabelPresenter but it hasn't updated the ParentRecord just yet.
I rewrote this to use a different approach. Rather than using a template selector I just provided a custom ContentTemplate and then used an IValueConverter to provide the appropriate text. This seems to work much better.
Hi Rob,
thank you for your fast reply. Unfortunatly, your solution has the same problem as mine. When you set the child record's column header, this column header is shown for all other child records. As you can see in my screenshot all child records column headers are set to only the last cell value "Seafood".
Maybe it is not possible to manipulate the column Header for every child record individually?
You can use the LabelPresenter's ContentTemplateSelector in order to adjust the column header. Take a look at my attached sample. Right now I set the column header of the child records to the value of a cell in the parent record.