This is a migrated thread and some comments may be shown as answers.

[Solved] Bind Data Column Header to Nested Type

1 Answer 87 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bill
Top achievements
Rank 1
bill asked on 25 Feb 2014, 12:26 AM

Hello,

  I have a grid that im trying to bind to a collection of customer objects. Each customer object contains a PrimaryAddress object. I would like to bind several of the grid columns to the PrimaryAddress object's fields as demonstrated below but it doesn't work.


​ <Grid:DataGridDateColumn HeaderStyle="{StaticResource HeaderStyle}" PropertyName="DisplayName" Header="Customer"/>
<Grid:DataGridDateColumn HeaderStyle="{StaticResource HeaderStyle}" PropertyName="PrimaryAddress.Address" Header="Address"/>
<Grid:DataGridDateColumn HeaderStyle="{StaticResource HeaderStyle}" PropertyName="PrimaryAddress.City" Header="City"/>
<Grid:DataGridDateColumn HeaderStyle="{StaticResource HeaderStyle}" PropertyName="PrimaryAddress.State" Header="State"/>

Any ideas?

Thank You,
Bill Spaulding

1 Answer, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 26 Feb 2014, 09:16 AM
Hello Bill,

Thank you for the question.

In this case you can use a DatGridTemplateColumn. The cell context is the data item and you can bind to its properties in the cell template:

<telerikGrid:DataGridTemplateColumn Header="Address">
    <telerikGrid:DataGridTemplateColumn.CellContentTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding PrimaryAddress.Address}"/>
        </DataTemplate>
    </telerikGrid:DataGridTemplateColumn.CellContentTemplate>
</telerikGrid:DataGridTemplateColumn>

I hope this helps. Let us know if you have further questions.

Regards,
Rositsa Topchiyska
Telerik
Tags
Grid for XAML
Asked by
bill
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Share this question
or