I want to bind my DataGrid to a data source that has some simple properties and an object. The second level collection is located in this inner object. How can I define this field in the top level grid to make xamDataGrid understand that this is the collection the second level grid will be bound to?
This property is named Sections held by the object WellDesign. The collection Sections is a BindingList. xamDataGrid tells me it is a collection, but that is all, when I run this view
<ig:XamDataGrid.FieldLayouts>
<ig:FieldLayout x:Name="designGrid" Tag="Sections" Settings="{StaticResource ReadWriteGridTwoHeaderRows}">
<ig:FieldLayout.Fields>
<ig:UnboundField Binding="{Binding WellDesign.Sections}" BindingMode="OneWay" Label="Sections" Column="1" Row="1" />
<ig:Field Name="CaseDesignId" Label="CaseDesignId" Column="2" Row="1"/>
<ig:Field Name="WellDesignId" Label="WellDesignId" Column="3" Row="1"/>
<ig:UnboundField Binding="{Binding WellDesign.DesignName}" BindingMode="OneWay" Label="Design" Column="4" Row="1" />
</ig:FieldLayout.Fields>
</ig:FieldLayout>
<ig:FieldLayout x:Name="sectionGrid" Settings="{StaticResource ReadWriteGridTwoHeaderRows}">
<ig:Field Name="SectionId" Column="0" Row="1" Label="Id" Settings="{StaticResource ReadOnlyTextFieldSettings}" />
<ig:Field Name="Name" Label="Name" Column="1" Row="1" Settings="{StaticResource ReadOnlyTextFieldSettings}" />
Hello Arnvid,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Thank you. Your hint helped me a lot. But in my application I had to apply the AssigningFieldLayoutToItem event also to fix this issue completely,
Regards
Arnvid
Hello,
I have been looking into your sample and I modified it so now it has the functionality you want. Basically I handled XamDataGrid’s FieldLayoutInitialized and set the Field’s DataType to ObservableCollection<Owner>. Also I can say that you are not able to bind the Label Property of a Field through the DataContext, because there it is null.
Hope this helps you.
Isolated sample enclosed. I want to address two issues:
1. Show me how to expand the Owners collection located in ThisCar object. I expect the datagrid to pick up the second FieldLayout, but it does not.
2. Show me how I can bind a DataItem property to the Label property for a Field/UnboundField entry.
See XAML code for first FieldLayout for the DataGrid.
I have been looking into your post, but it seems like that I am missing something in your scenario, so if this is still an issue for you, could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.