The new TemplateField class only seems to work on properties directly on the DataItem. However, I have a case where I want to combine several properties into one field. Previously I used an UnboundField and a custom ControlHostEditor as described elsewhere in this forum.
Do I still have to use ControlHostEditor for this scenario?
Can you suggest a way to do this without CellValuePresenterStyle or ControlHostEditor?
Hello,
Thank you for your post. I have been looking into it and I can suggest you see the sample in the Samples Browser under xamDataGrid / Editing & Selection / Template Fields section, where it is shown how to use TemplateField. Please let me know if this helps you or you have further questions on this matter. Looking forward for your reply.
Thank you Stefan for your very helpful reply. Let me provide you a little more information.
Here is a simplified example. We have a complex object property on the data being displayed in a XamDataGrid. We would like to show a field in the grid that is bound to a property on that complex object. Here is how we do it with UnboundField:
<igWPF:UnboundField Name="Description"
Binding="{Binding ExceptionMessageCodeInfo.Description}"
Label="{Binding Source={x:Static Resources:Label.Description}, Converter={StaticResource AllCapsConverter}}" />
I would like to use TemplateField to customize the presentation of this deep property but TemplateField does not support drilling into properties. I am asking if I am still dependent on the ControlHostEditor method or can I use TemplateField in this scenario?
This code snippet will not work because the property binding requires drilling down into a complex property on the DataItem.
<igWPF:TemplateField Width="250" Label="{Binding Source={x:Static Resources:Label.Type}, Converter={StaticResource AllCapsConverter}}"> <igWPF:TemplateField.DisplayTemplate> <DataTemplate> <TextBlock Text="{Binding ExceptionMessageCodeInfo.Description}" ToolTip="{Binding ExceptionMessageCodeInfo.HowToResolve}" /> </DataTemplate> </igWPF:TemplateField.DisplayTemplate> </igWPF:TemplateField>