I am new to XamDataGrid, so this may be an easy question.
One of the fields in my data-grid corresponds to a property which is a custom business object. I want to use this business object's "Description" property (of type String) as the text that gets displayed in the data-grid. So how do I do that? Please show the XAML.
As a temporary workaround, I overrode the business object's ToString() method, but this is not ideal.
Hi, You can achieve this with UnboundField in the xamDataGrid control.Let's have a business object - for example an object of type Person and the Person has a complex memeber FullName of type Name with two fields FirstName and LastName. You can display the FirstName and LastName in XAML in the following way:
<ig:XamDataGrid x:Name="igDataGrid" > <ig:XamDataGrid.FieldLayoutSettings> <ig:FieldLayoutSettings AutoGenerateFields="False" /> </ig:XamDataGrid.FieldLayoutSettings> <ig:XamDataGrid.FieldLayouts> <ig:FieldLayout> <ig:UnboundField Name="FirstName" Label="First Name" BindingPath="FullName.FirstName" /> <ig:UnboundField Name="LastName" Label="Last Name" BindingPath="FullName.LastName" /> </ig:FieldLayout> </ig:XamDataGrid.FieldLayouts></ig:XamDataGrid>
You can read more detailed description on this topic here:
http://help.infragistics.com/NetAdvantage/WPF/2010.3/CLR4.0/?page=xamDataPresenter_Displaying_a_Complex_Property_XAML.html
Best Regards
Thanks for the tip, although it didn't completely work. Initially it displays the correct value ("FirstName" and "LastName" in your example). But after switching to another screen where the value changes, then back to the XamDataGrid, the contents of ToString() are displayed instead of the updated value.
This looks to me like a Infragistics bug. I am using the 2010.1/CLR3.5 release. Has this since been fixed?
Hi, You are right about the side-effects. The BindingMode="TwoWay" should be added for the UnboundField-s.
<ig:UnboundField Name="FirstName" Label="First Name" BindingPath="FullName.FirstName" BindingMode="TwoWay" />
Hope this helps.
Adding BindingMode="TwoWay" made no difference, unfortunately.
Can you attach your example for further investigation?
I don't have time to pursue this further, so I'm going to stick with my original ToString() workaround.