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,
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
If you want to drill down into the properties then you can use normal Fields and set their BindingType Property to Unbound. This way they will act the same way as the old UnboundFields. You can set their Binding via the AlternateBinding Property. I attached a sample project whit this approach. Please let me know if 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>
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.