Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
Displaying Data From Child Objects
posted

Hi,

I have a collection of objects, each of which has a single child which for this example, we can call Order and OrderStatus.  If I bind my collection to my DataGrid, I can create columns for the primitive fields on the parent and I can create a column with the child's type but I cannot seem to figure out how to create columns with data from the child.  The relevant code is below. 

<!-- This code works and correctly displays the Id in the only column in the grid. -->

        <igDP:XamDataGrid Name="Orders" DataSource="{Binding}">
            <igDP:XamDataGrid.FieldLayoutSettings>
                <igDP:FieldLayoutSettings AutoGenerateFields="False" />
            </igDP:XamDataGrid.FieldLayoutSettings>
            <igDP:XamDataGrid.FieldLayouts>
                <igDP:FieldLayout>
                    <igDP:FieldLayout.Fields>
                        <igDP:Field Name = "Id" Label = "Id" />
                     </igDP:FieldLayout.Fields>
                </igDP:FieldLayout>
            </igDP:XamDataGrid.FieldLayouts>
        </igDP:XamDataGrid> 

<!-- This code does not work though similar code in other parts of my application does.  In fact, adding the bolded line causes the grid to not display any data at all -->

        <igDP:XamDataGrid Name="customerSpecialOrders" DataSource="{Binding}">
            <igDP:XamDataGrid.FieldLayoutSettings>
                <igDP:FieldLayoutSettings AutoGenerateFields="False" />
            </igDP:XamDataGrid.FieldLayoutSettings>
            <igDP:XamDataGrid.FieldLayouts>
                <igDP:FieldLayout>
                    <igDP:FieldLayout.Fields>
                        <igDP:Field Name = "Id" Label = "Id" />
                        <igDP:Field Name="{Binding OrderStatus.Description}" Label="Status" />
                    </igDP:FieldLayout.Fields>
                </igDP:FieldLayout>
            </igDP:XamDataGrid.FieldLayouts>
        </igDP:XamDataGrid>  

 Undoubtedly, this has to do with me not completely understanding WPF and/or the xamDataGrid yet but since it works in another part of my application using other WPF controls, I'm at a loss as to why it doesn't work with the xamDataGrid.  Any help would be greatly appreciated.

Brett 

Parents Reply Children
No Data