Hi,
I have these objects:
public class Cars
{
public String Make { get; set; }
}
public class Manufacturer
public String Address { get; set; }
I'm using a List<Cars> with an ObjectDataProvider to bind data to the grid. The question is how to show Manufacturers properties in the Grid (for example Manufacturers Addres). If I use the following code it doesn't work:
<igDP:FieldLayout.Fields> <igDP:Field Name="Name" Label="Car Name"> <igDP:Field Name="Make" Label="Car Make"> <igDP:Field Name="Manufacturer.Name" Label="Manufacturer Name"> <igDP:Field Name="Manufacturer.Address" Label="Manufacturer Address"> <igDP:Field Name="Manufacturer.City" Label="Manufacturer City"></igDP:FieldLayout.Fields>
How could I bind custom object properties to fields?
Thanks
Juan Puebla
In order to display a nested/complex property, you have to add UnboundField objects and set their BindingPath and BindingMode properties. For an example, click the links below:
An example in XAML
An example in C#/VB.NET
In your particular case, the following field definitions should work:
<igDP:FieldLayout.Fields> <igDP:Field Name="Name" Label="Car Name"> <igDP:Field Name="Make" Label="Car Make"> <igDP:UnboundField Name="ManufacturerName" BindingPath="Manufacturer.Name" BindingMode="TwoWay" Label="Manufacturer Name"> <igDP:UnboundField Name="ManufacturerAddress" BindingPath="Manufacturer.Address" BindingMode="TwoWay" Label="Manufacturer Address"> <igDP:UnboundField Name="ManufacturerCity" BindingPath="Manufacturer.City" BindingMode="TwoWay" Label="Manufacturer City"></igDP:FieldLayout.Fields>